stutego Posted January 20, 2013 Share Posted January 20, 2013 form not posting to database instead its redirecting me to another page with heading "object not found!" <?php $connect= mysql_connect("localhost", "username", "password"); if (!$connect) { die("could'nt connect to db:".mysql_error()); } mysql_select_db("myapp", $connect); $sql="INSERT INTO form(fname,lname,email,password,telephone,sex,dob) VALUES ('','$_POST[fname]', '$_POST[lname]', '$_POST[email]' '$_POST[password]', '$_POST[telephone]', '$_POST[sex]', '$_POST[dob]')"; if (!mysql_query($sql, $connect)) { die("Error:" .mysql_error()); } mysql_close($connect); function spamcheck($field) { $field = filter_var($field, FILTER_SANITIZE_EMAIL); if(filter_var ($field, FILTER_VALIDATE_EMAIL)) { return TRUE; } else { return FALSE; } } if (isset($_POST['email'])) { $mailcheck = spamcheck($_POST['email']); } if($mailcheck == FALSE) { //echo "invalid input"; } else { $email=$_POST['email']; $fname=$_POST['fname']; $lname=$_POST['lname']; $password=$_POST['password']; $retype_password=$password; $telephone=$_POST['telephone']; $sex=$_POST['sex']; $DOB=$_POST['dob']; } function yearOptions() { for ($i = 1910; $i <= date('Y'); $i++) { $s = date('Y') == $i ? ' selected="selected"' : ''; echo '<option '.$s.' value="'.$i.'">'.$i.'</option>'."\n"; } } function monthOptions() { $months = array( 1 => "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ); foreach ( $months as $monthNo => $month ) { ( $monthNo == date('n') ) ? $selected = ' selected="selected"' : $selected = ''; echo '<option value="'.$monthNo.'"'.$selected.'>'.$month.'</option>'."\n"; } } function dayOptions() { for ( $i = 1; $i <= 31; $i++ ) { ( $i == date('j') ) ? $selected = ' selected="selected"' : $selected = ''; echo '<option value="'.$i.'"'.$selected.'>'.$i.'</option>'."\n"; } } $password=$_POST["password"]; $salt=rand(100000,999999); $encrypted= (MD5(MD5($salt.$password))); if($retype_password!=$password) { echo "password mismatch"; } ?> <form action = "register.php" method=post> <fieldset> Firstname: <input type="text" size=30 name="fname"><br> Lastname: <input type="text" size=30 name="lname"><br> Email address: <input type=text size=30 name="email"><br> Password: <input type=password size=30 name="password"><br> Retype Password: <input type=password size=30 name="retype_password"><br> Telephone: <input type=tel size=30 name="telephone"><br> sex: <input type="radio" name="sex" value="male" checked="checked">Male<br/><input type="radio" name="sex" value="female">Female<br> Date of birth: <select name="dob"> <?php dayOptions();?> </select> <select name="dob"> <?php monthOptions();?> </select> <select name="dob"> <?php yearOptions();?> </select><br> <INPUT TYPE=SUBMIT VALUE="Register"> </fieldset> </form> Quote Link to comment https://forums.phpfreaks.com/topic/273397-form-not-posting-to-database/ Share on other sites More sharing options...
Christian F. Posted January 21, 2013 Share Posted January 21, 2013 Error: Not enough information, please read this. Quote Link to comment https://forums.phpfreaks.com/topic/273397-form-not-posting-to-database/#findComment-1407249 Share on other sites More sharing options...
albertdiones Posted February 4, 2013 Share Posted February 4, 2013 Make sure that <form action = "register.php" method=post> register.php actually exists. better yet, just remove it <form method=post> Quote Link to comment https://forums.phpfreaks.com/topic/273397-form-not-posting-to-database/#findComment-1409973 Share on other sites More sharing options...
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.