mariocesar Posted January 21, 2007 Share Posted January 21, 2007 Hello, this script is what you got after you login, if is something wrong it gives you a message if somenthing wrong when you're login, and if is ok it welcomes you and display 2 links, one to your account and another one to logout, how can I sent the visitor allready login to a different page without giving the welcome and the two links, just to a different page. thanks, here is the script.[code]<? if ($_POST[user] && $_POST[pass]) { $db = mysql_connect('localhost', $user = "digitalz_mario", $pass = "mario" ); mysql_select_db("digitalz_login", $db); $result = mysql_query ("SELECT * FROM usersreg WHERE name = '".$_POST[user]."'"); if (mysql_num_rows($result) == 0) { $result = mysql_query ("INSERT INTO usersreg (name, password, company, email, address, city, state, zipCode) VALUES ('".$_POST[user]."', PASSWORD('".$_POST[pass]."'),'".$company."', '".$email."', '".$address."', '".$city."', '".$state."', '".$zipCode."')"); if ($result) { $logged_in_user = $_POST[user]; session_register("logged_in_user"); echo "Your details have been added to the database, ".$_POST[user]. "<BR><BR>"; echo "to upload files go to your account.<BR><BR>"; echo "<div class='quote'><img src='images/orange_arrow.gif'> <A HREF='main.php'>My Account</A></div><br>"; echo "<div class='quote'><img src='images/orange_arrow.gif'> <A HREF='logout.php'>Logout</A></div><br>"; exit; } else { echo "Sorry, there has been a technical hitch. We cannot enter your details."; exit; } } else { echo "Sorry, that username has been taken. Please try another.<BR>"; } } else if ($_POST[user] || $_POST[pass]) { echo "Please fill in all fields.."; } ?>[/code]Thanks. Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 21, 2007 Share Posted January 21, 2007 header('Location: newpage.php'); Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted January 21, 2007 Share Posted January 21, 2007 well you could do a sort of validation code that "header();" to the account page....... you may have to uise the ob_start();, and ob_end_fluch();good luck Quote Link to comment Share on other sites More sharing options...
mariocesar Posted January 21, 2007 Author Share Posted January 21, 2007 I allready changed the line, but it gives me an error:Warning: Cannot modify header information - headers already sent by (output started at /home/digitalz/public_html/orderpstcards_login.php:10) in /home/digitalz/public_html/orderpstcards_login.php on line 85here is the code,[code]<? $links = "<div class='quote'><img src='images/orange_arrow.gif'> <A HREF='main.php'>My Account</A></div><br> <div class='quote'><img src='images/orange_arrow.gif'> <A HREF='logout.php'>Logout</A></div><br>"; if ($_POST[user] && $_POST[pass]) { if ($logged_in_user == $_POST[user]) { echo $_POST[user].", you are already logged in.<BR><BR>"; echo $links; exit; } $db = mysql_connect('localhost', $user = "digitalz_mario", $pass = "mario" ); mysql_select_db("digitalz_login", $db); $result = mysql_query("SELECT * FROM usersreg WHERE name = '".$_POST[user]."' AND password = PASSWORD('".$_POST[pass]."')"); if (!$result) { echo "Sorry, there has been a technical hitch. We cannot enter your details."; exit; } if (mysql_num_rows($result) > 0) { $logged_in_user = $_POST[user]; session_register("logged_in_user"); header('Location: orderpstcards_main.php'); exit; } else { echo "Invalid login. Please try again.<BR><BR>"; } } else if ($_POST[user] || $_POST[pass]) { echo "Please fill in both fields.<BR><BR>"; } ?>[/code]thanks in advance. Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 21, 2007 Share Posted January 21, 2007 Read the topic about header errors. Quote Link to comment Share on other sites More sharing options...
mariocesar Posted January 22, 2007 Author Share Posted January 22, 2007 Hi Jesirose, don't try to be all that, I know you know how to run this script, sometime you will need from some one else and then you won't like if they told you to go read a topic and solve your problem by your self, thanks any way, I solved it a friend gave me what I need and now the script is runnig fine, here is the script:echo ("<meta http-equiv=\"Refresh\" content=\"2; URL=orderpstcards_main.php\"/>Thank You! You will be redirected"); Quote Link to comment Share on other sites More sharing options...
trochia Posted January 22, 2007 Share Posted January 22, 2007 I'll interject here... reading is learning...( along with trial and error ) instead of being "spoon fed"...sorry...just a way to learn it... Break it down...by modules....and try it...that's what I do... Or else ask the guy who wrote most of the script...<laugh>PS>.. Running on 2 hours of sleep in 40+ hours... Quote Link to comment Share on other sites More sharing options...
trochia Posted January 22, 2007 Share Posted January 22, 2007 Is this a template you are modifing?? Quote Link to comment Share on other sites More sharing options...
mariocesar Posted January 22, 2007 Author Share Posted January 22, 2007 Hi Trochia, Are you in love with this girl? Quote Link to comment Share on other sites More sharing options...
trochia Posted January 22, 2007 Share Posted January 22, 2007 What girl? Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 22, 2007 Share Posted January 22, 2007 That doesn't actually fix your problem, and because you didn't read the topic you likely haven't learned how to solve the problem in the future. You were printing content to the browser before trying to redirect, you can't do that in PHP. You asked "how can I sent the visitor allready login to a different page without giving the welcome and the two links, just to a different page"Well, that's not what you're doing, now you're showing them the links and then redirecting them. If you want to do it like you asked, you have to restructure your code. Reading the topic I suggested would have helped. Quote Link to comment 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.