Redirect not working
-
I’m trying to redirect to another page after I hit the submit button on the form. But it doesn’t work no matter what redirection method I use. It goes to another page giving an error saying that the page doesn’t exist. it doesn’t even give the correct destination of my redirection page. I am only a beginner at php/wordpress so any help would be very much appreciated! because I’m at a loss as to what to do having spent days trying to get it to work.
Here is my code. Please help!
<form action="demo.php" method="POST"> <p>Name<input name="name" type="text" /></p> <p>Email<input name="email" type="text" /></p> <p>UserName<input name="user" type="text" /></p> <p>Password<input name="pass" type="password" /></p> <p>Confirm Password<input name="cpass" type="password" /></p> <p><input id="button" name="submit" type="submit" value="Sign Up" /></p> </form> <?php define('DB_NAME', 'wordpress'); define('DB_USER', 'root'); define('DB_PASSWORD', ''); define('DB_HOST', 'localhost'); $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if (!$link) { die('Could not connect: ' . mysql_error()); } $db_selected = mysql_select_db(DB_NAME, $link); if (!$db_selected){ die('Can\'t use ' . DB_NAME . ': ' . mysql_error()); } $fullname = $_POST['fullname']; $userName = $_POST['userName']; $email = $_POST['email']; $password = $_POST['password']; $sql = "INSERT INTO websiteusers (fullname, userName, email, password) VALUES ('$fullname','$userName','$email','$password')"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } if ($data) header("Location:http://localhost/wordpress/registration"); mysql_close(); function SignUp() { if(!empty($_POST['user'])) { $query = mysql_query("SELECT * FROM websiteusers WHERE userName = '$_POST[user]' AND pass = '$_POST[pass]'") or die(mysql_error()); if(!$row = mysql_fetch_array($query) or die(mysql_error())) { newuser(); } else { echo "Sorry. You are already a registered user"; } } } if(isset($_POST['submit'])) { SignUp(); }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Redirect not working’ is closed to new replies.