0

I have created a PHP file to store in my database but it displays nothing upon submit

it displays a blank page

12th Aug 2017, 11:21 AM
Abdul Shakur Abbas Sakhr
Abdul Shakur Abbas Sakhr - avatar
19 ответов
+ 1
that was what was displayed
12th Aug 2017, 12:53 PM
Abdul Shakur Abbas Sakhr
Abdul Shakur Abbas Sakhr - avatar
+ 1
and the data is not stored in the database
12th Aug 2017, 12:55 PM
Abdul Shakur Abbas Sakhr
Abdul Shakur Abbas Sakhr - avatar
0
What is the script in your file?
12th Aug 2017, 11:30 AM
Αητοιπe
Αητοιπe - avatar
0
<?php define('DB_SERVER', 'localhost'); define('DB_USERNAME', 'root'); define('DB_PASSWORD', ''); define('DB_DATABASE', 'e_cramer'); $db = mysqli_connect(DB_SERVER,DB_USERNAME,DB_PASSWORD,DB_DATABASE); ?> <?php if(isset($_POST["submit"])){ $firstname=$_POST['firstname']; $surname=$_POST['surname']; $username=$_POST['username']; $pwd=$_POST['pwd']; $cnf=$_POST['cnf']; $gender=$_POST['gender']; $dob=$_POST['dob']; $country=$_POST['country']; $email=$_POST['email']; $tel=$_POST['tel']; $address=$_POST['address']; $bloodgroup=$_POST['bloodgroup']; $sicklecell=$_POST['sicklecell']; $history=$_POST['history']; $firstname= mysqli_real_escape_string($db, $firstname); $surname= mysqli_real_escape_string($db, $surname); $username= mysqli_real_escape_string($db, $username); $pwd= mysqli_real_escape_string($db, $pwd); $pwd = md5($pwd); $cnf= mysqli_real_escape_string($db, $cnf); $gender= mysqli_real_escape_string($db, $gender); $dob= mysqli_real_escape_string($db, $dob); $country= mysqli_real_escape_string($db, $country); $email= mysqli_real_escape_string($db, $email); $tel= mysqli_real_escape_string($db, $tel); $address= mysqli_real_escape_string($db, $address); $bloodgroup= mysqli_real_escape_string($db, $bloodgroup); $sicklecell= mysqli_real_escape_string($db, $sicklecell); $history= mysqli_real_escape_string($db, $history);
12th Aug 2017, 11:49 AM
Abdul Shakur Abbas Sakhr
Abdul Shakur Abbas Sakhr - avatar
0
//authenticate username, password & email $sql = "SELECT username FROM registration WHERE username='$username'"; $result = mysqli_query($db,$sql); $row = mysqli_fetch_array($result,MYSQLI_ASSOC); if(mysqli_num_rows($result) == 1){ echo "Sorry...This username already exist.."; } else{ } $sql = "SELECT pwd FROM registration WHERE pwd='$pwd'"; $result = mysqli_query($db,$sql); $row = mysqli_fetch_array($result,MYSQLI_ASSOC); if(mysqli_num_rows($result) == 1){ echo "Sorry...password already exist.."; } else{ } $sql = "SELECT email FROM registration WHERE email='$email'"; $result = mysqli_query($db,$sql); $row = mysqli_fetch_array($result,MYSQLI_ASSOC); if(mysqli_num_rows($result) == 1){ echo "Sorry...This email already exist.."; } else{ } $query = mysqli_query($db, "INSERT INTO 'registration'(firstname,surname,username,pwd,cnf,gender,dob,country,email,tel,address,bloodgroup,sicklecell,history) VALUES('$firstname','$surname','$username','$pwd','$cnf','$gender','$dob','$country','$email','$tel','$address','$bloodgroup','$sicklecell','$history')"); if($query){ echo "Thank You! you are now registered."; } } ?>
12th Aug 2017, 11:50 AM
Abdul Shakur Abbas Sakhr
Abdul Shakur Abbas Sakhr - avatar
0
$db->prepare("INSERT INTO users ("firstname", "username"... ) VALUES($firstname, $username... ) )->execute
12th Aug 2017, 11:53 AM
Αητοιπe
Αητοιπe - avatar
0
you mean I should delete $query = mysqli_query ($db,
12th Aug 2017, 11:55 AM
Abdul Shakur Abbas Sakhr
Abdul Shakur Abbas Sakhr - avatar
0
and replace it with $db->prepare (
12th Aug 2017, 11:56 AM
Abdul Shakur Abbas Sakhr
Abdul Shakur Abbas Sakhr - avatar
0
Maybe but went I posted the message, your second message wasn't appear
12th Aug 2017, 12:00 PM
Αητοιπe
Αητοιπe - avatar
0
so what's wrong with my codes now?
12th Aug 2017, 12:02 PM
Abdul Shakur Abbas Sakhr
Abdul Shakur Abbas Sakhr - avatar
0
Try with prepare and execute by replacing "$ query = mysqli_query"
12th Aug 2017, 12:06 PM
Αητοιπe
Αητοιπe - avatar
0
it didn't work
12th Aug 2017, 12:11 PM
Abdul Shakur Abbas Sakhr
Abdul Shakur Abbas Sakhr - avatar
0
error appeared
12th Aug 2017, 12:11 PM
Abdul Shakur Abbas Sakhr
Abdul Shakur Abbas Sakhr - avatar
0
Maybe because you write ->execute instead of ->execute()
12th Aug 2017, 12:13 PM
Αητοιπe
Αητοιπe - avatar
0
on which line
12th Aug 2017, 12:16 PM
Abdul Shakur Abbas Sakhr
Abdul Shakur Abbas Sakhr - avatar
0
there is no ->execute in my codes
12th Aug 2017, 12:18 PM
Abdul Shakur Abbas Sakhr
Abdul Shakur Abbas Sakhr - avatar
0
$req = $db->prepare("INSERT INTO users SET username = ?, country = ?, gender= ?,... "); $req->execute([$username,$country,$gender]); Instead of: $query = mysqli_query...
12th Aug 2017, 12:36 PM
Αητοιπe
Αητοιπe - avatar
0
Ok let me try
12th Aug 2017, 12:37 PM
Abdul Shakur Abbas Sakhr
Abdul Shakur Abbas Sakhr - avatar
0
Warning: mysqli_stmt::execute() expects exactly 0 parameters, 1 given in C:\xampp\htdocs\assar\database.php on line 81 Thank You! you are now registered.
12th Aug 2017, 12:52 PM
Abdul Shakur Abbas Sakhr
Abdul Shakur Abbas Sakhr - avatar