I have a page that submits a form, and then I need it to redirect back to a previous page. What commands will I need for this?
Thanks
redirect (php newbie)
Moderator: General Moderators
Try:
You cannot print anyting before this command to the client. So the first thing your script i sending the client is the Location header. Otherwise you'll get an error.
Code: Select all
Header("Location: otherpage.php");- RandomEngy
- Forum Contributor
- Posts: 173
- Joined: Wed Jun 26, 2002 3:24 pm
- Contact:
-
dribbles9903
- Forum Newbie
- Posts: 4
- Joined: Tue Jul 23, 2002 3:17 pm
error message
k, that didn't work so I'm gonna give some more info as to what I've got.
input page = enter info into form, click to view your info
print1 = view your info, decide to either submit or go back
print2 = if submitted, print2 takes values sent from print1 and 'mail' s them. print2 is the page that i need redirected
here is the code for print2
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>EAHR: Send Student Form PHP</title>
</head>
<body>
<br><br>
<?php
Header("Location: student.php");
$send = "eahradvisor@coe.tamu.edu";
$subject = "Student Employment";
$body = "Fullname: $fullname \n";
$body.= "Date: $date \n";
$body.= "Social Security Number: $SSN \n";
$body.= "Email: $email \n";
$body.= "Home Address: $address \n";
$body.= "Phone Number: $phone \n";
$body.= "Fax Number: $fax \n";
$body.= "Primary skills: 1. $skill1 \n";
$body.= "2. $skill2 \n";
$body.= "3. $skill3 \n";
$body.= "4. $skill4 \n";
$body.= "5. $skill5 \n";
$body.= "Career Objectives: $objectives \n";
$body.= "Academic Department: $dept \n";
$body.= "Departmental Admission Date: $admdate \n";
$body.= "Degree Program: $degree \n";
$body.= "Semester: $semester \n";
$body.= "Year: $year \n";
$fromemail = $email;
mail( $send ,$subject , $body , $fromemail);
?>
</body>
</html>
input page = enter info into form, click to view your info
print1 = view your info, decide to either submit or go back
print2 = if submitted, print2 takes values sent from print1 and 'mail' s them. print2 is the page that i need redirected
here is the code for print2
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>EAHR: Send Student Form PHP</title>
</head>
<body>
<br><br>
<?php
Header("Location: student.php");
$send = "eahradvisor@coe.tamu.edu";
$subject = "Student Employment";
$body = "Fullname: $fullname \n";
$body.= "Date: $date \n";
$body.= "Social Security Number: $SSN \n";
$body.= "Email: $email \n";
$body.= "Home Address: $address \n";
$body.= "Phone Number: $phone \n";
$body.= "Fax Number: $fax \n";
$body.= "Primary skills: 1. $skill1 \n";
$body.= "2. $skill2 \n";
$body.= "3. $skill3 \n";
$body.= "4. $skill4 \n";
$body.= "5. $skill5 \n";
$body.= "Career Objectives: $objectives \n";
$body.= "Academic Department: $dept \n";
$body.= "Departmental Admission Date: $admdate \n";
$body.= "Degree Program: $degree \n";
$body.= "Semester: $semester \n";
$body.= "Year: $year \n";
$fromemail = $email;
mail( $send ,$subject , $body , $fromemail);
?>
</body>
</html>
- RandomEngy
- Forum Contributor
- Posts: 173
- Joined: Wed Jun 26, 2002 3:24 pm
- Contact:
Remember, you must do the header before you output any information to the page. Change it to something like this:
It's important not to have any HTML before you do your header().
Also, try getting in the habit of using $_POST['fieldname'] or $_GET['fieldname'] instead of just $fieldname .
Code: Select all
<?php
$send = "eahradvisor@coe.tamu.edu";
$subject = "Student Employment";
$body = "Fullname: $fullname \n";
...
$body.= "Year: $year \n";
$fromemail = $email;
mail( $send ,$subject , $body , $fromemail);
Header("Location: student.php");
?>Also, try getting in the habit of using $_POST['fieldname'] or $_GET['fieldname'] instead of just $fieldname .
-
dribbles9903
- Forum Newbie
- Posts: 4
- Joined: Tue Jul 23, 2002 3:17 pm