Jump to content

forward php page to another page


mariocesar

Recommended Posts

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'>&nbsp;&nbsp;<A HREF='main.php'>My Account</A></div><br>";
echo "<div class='quote'><img src='images/orange_arrow.gif'>&nbsp;&nbsp;<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.
Link to comment
Share on other sites

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 85

here is the code,

[code]<?
$links = "<div class='quote'><img src='images/orange_arrow.gif'>&nbsp;&nbsp;<A HREF='main.php'>My Account</A></div><br>
<div class='quote'><img src='images/orange_arrow.gif'>&nbsp;&nbsp;<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.
Link to comment
Share on other sites

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");
Link to comment
Share on other sites

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...
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.