HTML Tutorial


 Forum HomeForum Home   FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
RegisterRegister - Not registered yet? Got something to say? Join HTML Code Tutorial!
Form Question (from a real newbe)
Post new topic   Reply to topic    HTML Help Forum Index -> PHP
View previous topic :: View next topic  
Author Message
Spudnik



Joined: 09 Sep 2007
Posts: 1

PostPosted: Sun Sep 09, 2007 7:11 pm     Form Question (from a real newbe) Reply with quote

Hi

Hope someone might be able to help me with a simple form i am looking to run.

The form is in HTML format but is processed through a PHP script

See :
<?php
// initialize a variable to
// put any errors we encounter into an array
$errors = array();

// check to see if a name was entered
if (!$_POST['EmailAddress'])
// if not, add that error to our array
$errors[] = "Email Addess is Required";
// check to see if a subject was entered
if (!$_POST['Name'])
// if not, add that error to our array
$errors[] = "Name is required";
// if there are any errors, display them
if (count($errors)>0){
echo "<strong>ERROR:<br>\n";
foreach($errors as $err)
echo "$err<br>\n";
} else {
// no errors, so we build our message
$recipient = xxxxxxxxxatxxxxxx.com';
$from = stripslashes($_POST['Name']);
$subject = stripslashes($_POST['Subject']);
$msg = "Message sent by $from\n
".stripslashes($_POST['MsgBody']);
if (mail($recipient,$subject,$msg))
echo "Thanks for your message we will be in contact with you shortly!";
else
echo "An unknown error occurred.";
}
?>

It works fine for what i need but i would like it to go to a new url once submitted .

Eg : press submit then it new page loaded with echo "Thanks for your message we will be in contact with you shortly!"; then redirect to a www.isellstuff.com

Thanks in advance
flann



Joined: 04 May 2007
Posts: 14

PostPosted: Sun Sep 23, 2007 12:29 pm     Reply with quote

[php]
header ("Location: url.php");
[/php]

This will only work though if you haven't yet output headers. This means that if you echo out an error, it will fail.
Display posts from previous:   
Post new topic   Reply to topic    HTML Help Forum Index -> PHP All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
HTML Help Archive
Powered by phpBB © 2001, 2005 phpBB Group
HTML Help topic RSS feed 

 
HOSTING / DESIGN
MAKE MONEY

Home
  |   Tutorials   |   Forum   |   Quick List   |   Link Directory   |   About
Copyright ©1997-2002 Idocs and ©2002-2007 HTML Code Tutorial