Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

Redirection/Submit Problem

Asked Modified Viewed 10,843 times
M
MiraKaiba
M
  • Newbie, joined since
  • Contributed 2 posts on the community forums.
  • Started 1 thread in the forums
  • Started this discussions
asked
Newbie

I've been having a problem with some code for a submit form on my website. I have the code set up to send an email containing a message body of their name, email address, state, and some other information. I also have an else statement so that if the email and their name is not filled out, it gives them a message that says to go back to the form.

However, even when I fill out the name and email, it still gives me the message to go back to the form. Is there something wrong with my code?

Thanks


<?php

$name = $_POST['name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$address = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$zipcode = $_POST['zipcode'];
$questions = $_POST['questions'];



$message_body =
"\n" .
"\n" .
"Name: "  . $name . "\n" .
"\n" .
"Phone: " . $phone . "\n" .
"\n" .
"Email: " . $email . "\n" .
"\n" .
"Address: " . $address . "\n" .
"         " . $city . ", " . $state . "  " . $zipcode . "\n" .

"Questions: " . $questions;

$subject = "INQUIRY FROM CELEBRATIONS SITE";

if ($name AND $email) {
   mail ("info@dvdgraduationinvitations.com", $subject, $message_body, "From: $email");
   header ("Location: http://www.dvdgraduationinvitations.com/processContactg2.php");
} else {
   print ("<p>Please enter all required information</p>
         <p>Use the back button on your browser to return to the form</p>
         \n");
}
   
?>
0 replies

4 posts

X
Xessive
X
I am not always right, but I'm never wrong.
http://www.xessive.nl
  • Senior Member, joined since
  • Contributed 327 posts on the community forums.
  • Started 4 threads in the forums
answered
Senior Member

Try:

If (!empty($_POST['name]) && !empty($_POST['email]) {
Send mail code here
} else {
Other code here
}
Edited by Xessive on 29-07-2008 10:27,
0 replies
M
MiraKaiba
M
  • Newbie, joined since
  • Contributed 2 posts on the community forums.
  • Started 1 thread in the forums
  • Started this discussions
answered
Newbie

I will definitely try the !empty script.

Here is how I have the form set up within my html.

<form method="post" action="http://www.dvdgraduationinvitations.com/processContactg2.php" >


And my fields:

<p><b>Name:</b> <Input type="text" name="name" id="name" size="25" /></p>


And my submit:

<p><input type=Submit value="Submit Your Request" onclick="processContactg2.php"></p>


This looks correct to me - the name and email fields are named correctly. If you see any issues, please let me know.
0 replies
G
googlebot
G
Visit the new home of the merge between Hacking Vs. Security and Security Override!
My copyright removal has been switched over from HvS to SecurityOverride.
  • Senior Member, joined since
  • Contributed 638 posts on the community forums.
  • Started 28 threads in the forums
answered
Senior Member

Quote

TammyK wrote:
BTW, you REALLY need to check your variables. $email needs to be a valid email and only a valid email.

http://www.google.com/search?hl=en&am...gle+Search

Oh, and the first result is interesting. I just skimmed the code, but maybe you guys should look into that for v7's release: http://www.phpit.net/code/valid-email/
0 replies
X
Xessive
X
I am not always right, but I'm never wrong.
http://www.xessive.nl
  • Senior Member, joined since
  • Contributed 327 posts on the community forums.
  • Started 4 threads in the forums
answered
Senior Member

Quote

googlebot wrote:

Quote

TammyK wrote:
BTW, you REALLY need to check your variables. $email needs to be a valid email and only a valid email.

http://www.google.com/search?hl=en&am...gle+Search

Oh, and the first result is interesting. I just skimmed the code, but maybe you guys should look into that for v7's release: http://www.phpit.net/code/valid-email/


try registering at a V7 site (dunno if V6 already supported it) using a invalid email address, but you'll get the
following message:

Registration failed for the following reason(s):

Your email address does not appear to be valid.
Incorrect validation code.

Please Try Again
0 replies

Category Forum

Bugs and Errors - 6

Labels

None yet

Statistics

  • Views 0 views
  • Posts 4 posts
  • Votes 0 votes
  • Topic users 3 members

0 participants

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet