Jump to content

Recommended Posts

[b]Solved, code that fixed it at the bottom[/b]

I am having a problem now, I moved on to validation.
I have my form
[code]
<form name="ideasandsubmissionsform" action="../cgi-bin/form-processors/ideasandsubmissionsprocessor.php" method="post">
<fieldset class="formstyle">
<legend>Ideas and Submissions</legend><br />
<label for="firstname" accesskey="f">*First Name:</label><br />
<input tabindex="1" name="firstname" id="firstname" type="text" maxlength="30" value="<?php echo $_POST["firstname"]; ?>" /><br />
<label for="emailaddress" accesskey="e">*Email Address:</label><br />
<input tabindex="2" name="emailaddress" id="emailaddress" type="text" maxlength="80" value="<?php echo $_POST["emailaddress"]; ?>" /><br />
<label for="verifyemail" accesskey="v">*Verify Email:</label><br />
<input tabindex="3" name="verifyemail" id="verifyemail" type="text" maxlegth="80" />
<br />
<label for="description" accesskey="m">*Description:</label><br />
<textarea tabindex="4" name="description" id="description" rows="6" cols="30">
</textarea><br />
<input tabindex="5" name="submit" id="submit" type="submit" value="submit" />
<input tabindex="6" name="reset" id="reset" type="reset" value="reset" />
</fieldset>
</form>
[/code]
I am wondering because I get this error
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
Parse error: parse error, unexpected T_ISSET, expecting '(' in /home/freelan4/public_html/cgi-bin/form-processors/ideasandsubmissionsprocessor.php on line 9
[/quote]
here is my php code
[code]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>ideasandsubmissionsprocessor.php</title>
</head>
<body>
<?php
if isset($_POST['firstname'] == ""){
print("You have not correctly filled out the First name.  Please hit back and fix the errors");
}if isset($_POST['emailaddress'] == ""){
print("You have not correctly filled in the first name.  Please hit back and fix the errors");
}if isset($_POST['verifyemail'] == ""){
print("You have not correctly filled in the verify email field.  Please hit back and fix the errors");
}if isset($_POST['description'] == ""){
print("You have not correctly filled int he verify email field.  Please hit the back and fix the errors");
}
?>



<?php
$firstname = $_POST['firstname'];
$emailaddress = $_POST['emailaddress'];
$verifyemail = $_POST['verifyemail'];
$description = $_POST['description'];
$to = "businessman332211@hotmail.com";
$subject = "ideas and submissions";
$message = "
First Name: $firstname
Email Address: $emailaddress
Verify Email: $verifyemail
Description: $description
";

if(mail($to, $subject, $message)) {
print("Thank you for submitting your email has been successfully sent");
print("<br />Return to the homepage at <a href='http://www.freelancebusinessman.com'>Freelance Businessman</a>");
}else{
print("I am sorry but there was some sort of error and the email could not be sent");
print("<br />I am not totally sure of the cause of this error.");
print("<br />Please return to <a href='http://www.freelancebusinessman.com'>Freelance Businessman</a>");
print("<br />If you try again and recieve this error message a second time, then please email me at the original email address and notify me of this error, so it can be checked into.  Thank you for visiting Freelance Businessman.");
}

?>
</body>
</html>
[/code]
I haven't really started putting in the advanced validation using c-type yet, but when i put something basic like this, what I am trying to do is test all fields to make sure they have atleast something in them, then I was going to put more functions to check for other things. But right now just checking for validation, when I added that in above my email functions and everything it started to give me an error. Any advice, thanks.

I played with it some, this is how my php code looks now
[code]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>ideasandsubmissionsprocessor.php</title>
</head>
<body>
<?php
if ($_POST['firstname'] == ""){
print("You have not correctly filled out the First name.  Please hit back and fix the errors");
}if ($_POST['emailaddress'] == ""){
print("You have not correctly filled in the first name.  Please hit back and fix the errors");
}if ($_POST['verifyemail'] == ""){
print("You have not correctly filled in the verify email field.  Please hit back and fix the errors");
}if ($_POST['description'] == ""){
print("You have not correctly filled int he verify email field.  Please hit the back and fix the errors");
}
?>



<?php
$firstname = $_POST['firstname'];
$emailaddress = $_POST['emailaddress'];
$verifyemail = $_POST['verifyemail'];
$description = $_POST['description'];
$to = "businessman332211@hotmail.com";
$subject = "ideas and submissions";
$message = "
First Name: $firstname
Email Address: $emailaddress
Verify Email: $verifyemail
Description: $description
";

if(mail($to, $subject, $message)) {
print("Thank you for submitting your email has been successfully sent");
print("<br />Return to the homepage at <a href='http://www.freelancebusinessman.com'>Freelance Businessman</a>");
}else{
print("I am sorry but there was some sort of error and the email could not be sent");
print("<br />I am not totally sure of the cause of this error.");
print("<br />Please return to <a href='http://www.freelancebusinessman.com'>Freelance Businessman</a>");
print("<br />If you try again and recieve this error message a second time, then please email me at the original email address and notify me of this error, so it can be checked into.  Thank you for visiting Freelance Businessman.");
}

?>
</body>
</html>
[/code]
now it is checking it right, and validating it right, but it also sends the email even if the fields fail, I don't understand how to get it to work through the process correctly, I will keep playing with it, maybe I can figure out something, but any help would be greatly appreciated.

I fixed the problem by doing this, I can go from there now, thanks
[code]

<?php
if ($_POST['firstname'] == ""){
print("You have not correctly filled out the First name.  Please hit back and fix the errors");
}if ($_POST['emailaddress'] == ""){
print("You have not correctly filled in the first name.  Please hit back and fix the errors");
}if ($_POST['verifyemail'] == ""){
print("You have not correctly filled in the verify email field.  Please hit back and fix the errors");
}if ($_POST['description'] == ""){
print("You have not correctly filled int he verify email field.  Please hit the back and fix the errors");
} else{
$firstname = $_POST['firstname'];
$emailaddress = $_POST['emailaddress'];
$verifyemail = $_POST['verifyemail'];
$description = $_POST['description'];
$to = "businessman332211@hotmail.com";
$subject = "ideas and submissions";
$message = "
First Name: $firstname
Email Address: $emailaddress
Verify Email: $verifyemail
Description: $description
";

if(mail($to, $subject, $message)) {
print("Thank you for submitting your email has been successfully sent");
print("<br />Return to the homepage at <a href='http://www.freelancebusinessman.com'>Freelance Businessman</a>");
}else{
print("I am sorry but there was some sort of error and the email could not be sent");
print("<br />I am not totally sure of the cause of this error.");
print("<br />Please return to <a href='http://www.freelancebusinessman.com'>Freelance Businessman</a>");
print("<br />If you try again and recieve this error message a second time, then please email me at the original email address and notify me of this error, so it can be checked into.  Thank you for visiting Freelance Businessman.");
}
}
?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/9932-error-with-validation-and-mail/
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.