Can i get some php help please

[php]

<?php $con = mysqli_connect('localhost','root','','prankvsprank'); if (mysqli_connect_errno()){ echo"Failed to connect_2" . mysqli_connect_error(); } else { echo" Connected To Database_2"; } $lUsername = @$_POST['lUsername']; $lPassword = @$_POST['lPasssword']; $lSubmit = @$_POST['lsubmit']; if(@$_POST['lsubmit']){ if(!empty($lUsername) && !empty($lPassword)){ $login = "SELECT * FROM prankvsprank WHERE username = '$lUsername' AND password = '$lPassword'"; $res = mysqli_query($login) or die(mysqil_error()); if(mysqli_num_rows($res) != 0) { echo "Logged in"; } else { echo "Error_2"; } } } ?> Login Login
Username:
Password:
[/php]

First I never understand why people use @ to suppress warnings, specially when you are developing the script.

// Set your connection string to connect to a database

// The database is the only thing that you will have to setup in MySQL

[php]$con = new mysqli(“localhost”, “root”, “your_password”, “prankvsprank”);

/* check connection */
if (mysqli_connect_errno()) {
printf(“Connect failed: %s\n”, mysqli_connect_error());
exit();
}

if (isset($_POST[‘lsubmit’]) && $_POST[‘lsubmit’] == ‘submit’) {
$query = “SELECT * FROM prankvsprank WHERE username = ? AND password = ?”;
// More code goes here, you are using mysqli - you might as well check into prepared statements.
}[/php]

Sorry, I have to run, maybe this will get you started or someone else can help you more.

Start with getting rid of all the @ symbols and never use them again. Error messages are your friend. They let you know something is broken :o

Sponsor our Newsletter | Privacy Policy | Terms of Service