cool_techie Posted November 6, 2010 Share Posted November 6, 2010 Hello everyone, I am new to php,and i am making my website......where i am unable to redirect a user to his respctive homepage.. Can anyone help me out with a sample script.......... Thanks, cool_techie Link to comment https://forums.phpfreaks.com/topic/217939-php-redirect/ Share on other sites More sharing options...
Pikachu2000 Posted November 6, 2010 Share Posted November 6, 2010 Post the code you currently have and tell us what problems you're having with it, specifically. Link to comment https://forums.phpfreaks.com/topic/217939-php-redirect/#findComment-1131095 Share on other sites More sharing options...
cool_techie Posted November 6, 2010 Author Share Posted November 6, 2010 Sir,i used the following code for trial purpose to see if i suceed.......... But it is showing no effect....no errors r being generated but no output is being given....it renders a blank page.. <?php $dbConnect = mysql_pconnect("localhost", "root") or die("Cannot connect database"); mysql_select_db("ABC") or die("Cannot select database"); $user = $_GET['uname']; $passwd = $_GET['passwd']; if (isset($_GET['submit'])) { $query = "select `fname`, `password` FROM details WHERE `fname`='$user' AND `password`='$passwd'"; $result=mysql_query($query); if(mysql_num_rows($result) == 1) { header('Location:C:\xampp\htdocs\ABCcinemas\index1.html\'); } else { echo "No match found !<hr />"; } } ?> Link to comment https://forums.phpfreaks.com/topic/217939-php-redirect/#findComment-1131121 Share on other sites More sharing options...
MSUK1 Posted November 6, 2010 Share Posted November 6, 2010 please post it in the php brackets next time <?php $dbConnect = mysql_pconnect("localhost", "root") or die("Cannot connect database"); mysql_select_db("ABC") or die("Cannot select database"); $user = $_GET['uname']; $passwd = $_GET['passwd']; if (isset($_GET['submit'])) { $query = "select `fname`, `password` FROM details WHERE `fname`='$user' AND `password`='$passwd'"; $result=mysql_query($query); if(mysql_num_rows($result) == 1) { header('Location:C:\xampp\htdocs\ABCcinemas\index1.html\'); } else { echo "No match found !<hr />"; } } ?> what exactly is happening when this code is executed nothing? Link to comment https://forums.phpfreaks.com/topic/217939-php-redirect/#findComment-1131130 Share on other sites More sharing options...
radar Posted November 6, 2010 Share Posted November 6, 2010 $_GET gathers information from the browser, with tue $_GET['submit'] this makes me think that you are using a form probably in the form of a login form. So in that case you'd change all your $_GET to $_POST if it truely is a GET you are using, make sure you echo it out like: <?php echo "<pre>"; print_r($_GET); echo "</pre>"; ?> that'll help you to see what values you do have in an array, it also outputs it in an easy to read fashion so you can help to debug your solution. Although my money is on changing $_GET to $_POST Link to comment https://forums.phpfreaks.com/topic/217939-php-redirect/#findComment-1131134 Share on other sites More sharing options...
cool_techie Posted November 7, 2010 Author Share Posted November 7, 2010 Hello , I have 1 more query.... If i have made my form's method as POST......and i have used GET in my php script will it work........ Link to comment https://forums.phpfreaks.com/topic/217939-php-redirect/#findComment-1131299 Share on other sites More sharing options...
radar Posted November 7, 2010 Share Posted November 7, 2010 no, 'cause your forms method is always post.. $_GET always gets from the browser address bar... $_REQUEST gets from either (not a failsafe method though)... recommended usage is $_GET from browser, $_POST from forms. Link to comment https://forums.phpfreaks.com/topic/217939-php-redirect/#findComment-1131306 Share on other sites More sharing options...
cool_techie Posted November 7, 2010 Author Share Posted November 7, 2010 hello, Sir now i am using the following code...but the redirected page is completely blank.... My code is: <?php { $dbConnect = mysql_pconnect("localhost", "root") or die("Cannot connect database"); mysql_select_db("ABC") or die("Cannot select database"); $user = $_POST['uname']; $passwd = $_POST['passwd']; if (isset($_POST['submit'])) { $query = "select `fname`, `password` FROM details WHERE `fname`='$user' AND `password`='$passwd'"; $result=mysql_query($query); if(mysql_num_rows($result) == 1) { header('Location:C:\xampp\htdocs\ABCcinemas\index1.html'); } else { echo "No match found !<hr />"; } } } ?> sir please help me out with...it... Link to comment https://forums.phpfreaks.com/topic/217939-php-redirect/#findComment-1131339 Share on other sites More sharing options...
radar Posted November 7, 2010 Share Posted November 7, 2010 if you are using xampp you should be accessing your site via http://localhost/ in which case, i'm guessing the form is on index.php or index.html or the like. so your header would be: header("LOCATION:index1.html"); Link to comment https://forums.phpfreaks.com/topic/217939-php-redirect/#findComment-1131341 Share on other sites More sharing options...
cool_techie Posted November 7, 2010 Author Share Posted November 7, 2010 yes sir,i am using it on xampp via http://localhost and my form is on index.html.....which uses php script login.php now when i tried header("location:index1.html") there was no effect............the redirected page is blank.....and in address bar contains address of login.php Link to comment https://forums.phpfreaks.com/topic/217939-php-redirect/#findComment-1131368 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.