barry6628 Posted February 25, 2008 Share Posted February 25, 2008 Hi This will be easy for you ? I have a validation form after input from the customer $affected_rows = mysql_num_rows($result); if($affected_rows == 1){ print 'Validated'; } else { print 'Not Validated'; } Instead of printing Validate I want the code to go directly back to the index.php How do I do it. Regards, and thanks Barry Quote Link to comment https://forums.phpfreaks.com/topic/92893-link-back-to-indexphp/ Share on other sites More sharing options...
revraz Posted February 25, 2008 Share Posted February 25, 2008 Use header if no output has been sent to the browser or use HTML redirect if output has been sent. Quote Link to comment https://forums.phpfreaks.com/topic/92893-link-back-to-indexphp/#findComment-475830 Share on other sites More sharing options...
barry6628 Posted February 25, 2008 Author Share Posted February 25, 2008 Thanks Sorry I forgot to add I dont want the user to have to ineract ie: press anothe buton. Quote Link to comment https://forums.phpfreaks.com/topic/92893-link-back-to-indexphp/#findComment-475850 Share on other sites More sharing options...
aebstract Posted February 25, 2008 Share Posted February 25, 2008 if($affected_rows == 1){ header("Location: index.php"); } else { print 'Not Validated'; } Quote Link to comment https://forums.phpfreaks.com/topic/92893-link-back-to-indexphp/#findComment-475853 Share on other sites More sharing options...
revraz Posted February 25, 2008 Share Posted February 25, 2008 Doesn't apply to either way. Sorry I forgot to add I dont want the user to have to ineract ie: press anothe buton. Quote Link to comment https://forums.phpfreaks.com/topic/92893-link-back-to-indexphp/#findComment-475855 Share on other sites More sharing options...
barry6628 Posted February 25, 2008 Author Share Posted February 25, 2008 Sorry yet again Ill let you have all the page. <?php session_start(); ?> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <body> <?php $check_name = $_POST['userName']; $check_password = $_POST['password']; echo "$check_name"; echo "$check_password"; mysql_connect("xxxxxxxxxxxx","xxxxxxxxxxxx","xxxxxxxxx") or die("Could not connect to MySQL server!"); mysql_select_db("xxx") or die("Could not select database!"); echo "selected db"or die("Could not select database!"); $result = mysql_query("SELECT * FROM accounts WHERE fname = '$check_name' AND password = '$check_password' ") or die(mysql_error()); $affected_rows = mysql_num_rows($result); if($affected_rows == 1){ header("Location: index.php"); } else { print 'Not Validated'; } /*if($affected_rows == 1){ print 'Validated'; } else { print 'Not Validated'; } */ ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/92893-link-back-to-indexphp/#findComment-475871 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.