ostig Posted March 30, 2008 Share Posted March 30, 2008 I have created two scripts for user authentication and I am stuck as to how to get the user where I want him/her to go. The first script gets the username and password using a form and goes to a second script for validation. The validation script validates that the user name and password are correct by comparing to MySQL DB. Now I am stuck as I am very new to php (one day) and just have a "Dummies" book at the moment. If the username and password is good, I need to automatically send the user to another URL. If the username is not good, I need to automatically send the user back to the first script's URL. If the password is no good, I need to automatically send the user to an information page about what they can do. My problem is I cannot figure how to automatically send the user anywhere (whichout them clicking on something). I looked at the header command, but to me it seems it is not an option because I am going to be sending them elsewhere in the middle of a php script inside of if statements and what I read seems like this is not such a good way to go as the header command needs to be first? Any help appreciated! Link to comment https://forums.phpfreaks.com/topic/98656-automatically-send-user-to-new-domainpage/ Share on other sites More sharing options...
ohdang888 Posted March 30, 2008 Share Posted March 30, 2008 echo this: <meta http-equiv='refresh' content='0;url=page.php'> Link to comment https://forums.phpfreaks.com/topic/98656-automatically-send-user-to-new-domainpage/#findComment-504898 Share on other sites More sharing options...
trq Posted March 30, 2008 Share Posted March 30, 2008 The header function does not need to be first, it just needs to be before any output. This makes perfect sense as there is no point outputting anything if all your going to do is redirect the user anyway. <?php header('Location: http://domain.com/somepage.php'); ?> Link to comment https://forums.phpfreaks.com/topic/98656-automatically-send-user-to-new-domainpage/#findComment-504901 Share on other sites More sharing options...
ostig Posted March 30, 2008 Author Share Posted March 30, 2008 Okay, those two command work for me when I am sending to a URL, as requested, thank you. ----- But now to add to the level of complexity, last evening I learned how to do this: <a href="domain.com/index.htm?color=<?php echo $color; ?>&date=<?php echo $date; ?>" .... in order to send to contents of a variable appended to the end of a URL, as shown. Problem is that this will not work for me when I try it in the meta or header command (which I guess is what I have to use to send the user to the new URL), I get parse errors. Am I now up against something that is not valid? For this task I am required to send up to 5 variable=value strings at the end of the URL. Link to comment https://forums.phpfreaks.com/topic/98656-automatically-send-user-to-new-domainpage/#findComment-504981 Share on other sites More sharing options...
wmguk Posted March 30, 2008 Share Posted March 30, 2008 Okay, those two command work for me when I am sending to a URL, as requested, thank you. ----- But now to add to the level of complexity, last evening I learned how to do this: <a href="domain.com/index.htm?color=<?php echo $color; ?>&date=<?php echo $date; ?>" .... in order to send to contents of a variable appended to the end of a URL, as shown. Problem is that this will not work for me when I try it in the meta or header command (which I guess is what I have to use to send the user to the new URL), I get parse errors. Am I now up against something that is not valid? For this task I am required to send up to 5 variable=value strings at the end of the URL. you should be able to <?PHP //PAGE TEXT echo "<meta http-equiv='refresh' content='0;url=page.php?color=$color&date=$date'>" ; ?> Link to comment https://forums.phpfreaks.com/topic/98656-automatically-send-user-to-new-domainpage/#findComment-504987 Share on other sites More sharing options...
ostig Posted March 30, 2008 Author Share Posted March 30, 2008 That works. Thanks! Topic closed / solved. Link to comment https://forums.phpfreaks.com/topic/98656-automatically-send-user-to-new-domainpage/#findComment-504998 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.