codedman 0 Posted January 30 Share Posted January 30 please, what is my mistake here? <?php // This function will run within each post array including multi-dimensional arrays function ExtendedAddslash(&$sql){ foreach($sql as $sql){ // check if $var is an array. If yes, it will start another ExtendedAddslash() function to loop to each key inside. is_array($sql) ? ExtendedAddslash($sql) : $sql=addslashes($sql); } } // Initialize ExtendedAddslash() function for every $_POST variable ExtendedAddslash($_POST); if ($_POST["submit"]==true) echo'you submitted this form'; else{ echo'You are yet to complete your form'; } $fname=$_POST["fname"]; $sname=$_POST["sname"]; $lname=$_POST["lname"]; $dept=$_POST["dept"]; $school=$_POST["school"]; $faculty=$_POST["faculty"]; $level=$_POST["level"]; $email=$_POST["email"]; $course=$_POST["course"]; $psw=$_POST["psw"]; $servername = "localhost:3306"; $username = "admin"; $password = "Ilove081."; $dbname = "school"; // Create connection $conn =mysqli_connect($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } else { echo'<hr/>'; } // Attempt insert query execution $sql = "INSERT INTO register (id,firstname,surname, lastname,department,school,faculty,level, email,course,password,reg_time) VALUES ('',$fname,$sname, $lname,$dept,$school,$faculty,$level, $email,$course,$password,CURRENT_TIME_STAMP)"; if(mysqli_query($conn, $sql)){ echo "Records inserted successfully."; } else{ echo "ERROR: Couldn't upload your data. Please, kindly try again. this is the error message<br/> $sql. " . mysqli_error($conn); } // Close connection mysqli_close($conn); ?> <div> <p align="center"> <h2>Below are the information you submitted;</h2><br/> <ol> <li><em>Firstname:</em> <?php echo $fname?></li> <li><em>Email:</em> <?php echo $email?></li> <li><em>School:</em> <?php echo $school?></li> <li><em>Course:</em> <?php echo $course?></li> </ol> </p> </div> kindly correct me Quote Link to post Share on other sites
requinix 982 Posted January 30 Share Posted January 30 http://www.catb.org/~esr/faqs/smart-questions.html Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.