Menu list sendmail .php
Moderator: General Moderators
Menu list sendmail .php
Hi I am having a problem with the code below I am using to send a simple php email form with no database.
I am not that advanced with php but I want to add a drop down menu to a form I created and not sure how to get get the message (warning not completed) in the field - if(empty($visitortitle)) { - to accept or not to accept?
This is the code in the form:
<td align="left"><select name="visitortitle">
<option>Please Select</option>
<option>Mr</option>
<option>Mrs</option>
<option>Miss</option>
<option>Ms</option>
<option>Dr</option>
</select>
This is the code I have got in the sendemail:
if(empty($visitortitle)) {
echo "<h2><br /><br /><br /><br />Please hit the back button and enter the title drop down box correctly<br />before you try submitting the form again.</h2>\n";
die ( '<a href="forum.html">click here go back and try again</a>' );
}
How can I get this code to recognise that a <option></option> has been selected?
Any help would be appreciated.
Thanks
Gary
I am not that advanced with php but I want to add a drop down menu to a form I created and not sure how to get get the message (warning not completed) in the field - if(empty($visitortitle)) { - to accept or not to accept?
This is the code in the form:
<td align="left"><select name="visitortitle">
<option>Please Select</option>
<option>Mr</option>
<option>Mrs</option>
<option>Miss</option>
<option>Ms</option>
<option>Dr</option>
</select>
This is the code I have got in the sendemail:
if(empty($visitortitle)) {
echo "<h2><br /><br /><br /><br />Please hit the back button and enter the title drop down box correctly<br />before you try submitting the form again.</h2>\n";
die ( '<a href="forum.html">click here go back and try again</a>' );
}
How can I get this code to recognise that a <option></option> has been selected?
Any help would be appreciated.
Thanks
Gary
Re: Menu list sendmail .php
Assign values to your optionsghi572000 wrote:How can I get this code to recognise that a <option></option> has been selected?
Code: Select all
<option value="Mr">Mr</option>
<option value="Mrs">Mrs</option>
etc.Re: Menu list sendmail .php
Thanks Celauran
tried that but still did not work?
I have now got this far:
47 if(isset($_POST['visitortitle'])) {$visitortitle = $_POST['visitortitle'];} else {$visitortitle = 'Nothing Selected';}
48 echo $visitortitle; "<h2><br /><br /><br /><br />Please hit the back button and fill in your full name correctly<br
49 />before you try submitting the form again.</h2>\n";
50 die ( '<a href="forum.html">click here go back and try again</a>' );
51 }
but now I am now getting the error message below:
Parse error: syntax error, unexpected '}' thankyou_forum.php on line 51
tried that but still did not work?
I have now got this far:
47 if(isset($_POST['visitortitle'])) {$visitortitle = $_POST['visitortitle'];} else {$visitortitle = 'Nothing Selected';}
48 echo $visitortitle; "<h2><br /><br /><br /><br />Please hit the back button and fill in your full name correctly<br
49 />before you try submitting the form again.</h2>\n";
50 die ( '<a href="forum.html">click here go back and try again</a>' );
51 }
but now I am now getting the error message below:
Parse error: syntax error, unexpected '}' thankyou_forum.php on line 51
Re: Menu list sendmail .php
Remove the curly brace at the end of line 47.
Re: Menu list sendmail .php
Thanks again Celauran still did not help but here is the full view of my coding:
The code I'm using in the post html below:
<form method="post" action="thankyou_forum.php">
<?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>
<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
<input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />
<tr>
<td align="right">Title:</td>
<td> </td>
<td align="left"><select name="visitortitle">
<option>Please Select</option>
<option value="Mr">Mr</option>
<option value="Mrs">Mrs</option>
<option value="Miss">Miss</option>
<option value="Ms">Ms</option>
<option value="Dr">Dr</option>
</select>
</td>
</tr>
<td>
<label>
<input name="button" type="submit" id="button" value="Send" />
</label>
</td>
</tr>
</form>
Okay now the code I have in the sendemail php page:
<?php
$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$visitor = $_POST['visitor'];
$visitormail = $_POST['visitormail'];
$notes = $_POST['notes'];
$attn = $_POST['attn'];
if (eregi('http:', $notes)) {
die ("Please enter your message before you try submitting the form.");
}
if(isset($_POST['visitortitle'])) {$visitortitle = $_POST['visitortitle'];} else {$visitortitle = 'Nothing Selected';}
echo "<h2><br /><br /><br /><br />Please hit the back button and fill in your full name correctly<br />before you try submitting the form again.</h2>\n";
die ( '<a href="forum.html">click here go back and try again</a>' );
}
$from = "From: $visitor\r\n";
$message = " $todayis [EST] \n
Title: $visitortitle \n ";
mail("name@domain.com", $visitortitle);
?>
The code I'm using in the post html below:
<form method="post" action="thankyou_forum.php">
<?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>
<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
<input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />
<tr>
<td align="right">Title:</td>
<td> </td>
<td align="left"><select name="visitortitle">
<option>Please Select</option>
<option value="Mr">Mr</option>
<option value="Mrs">Mrs</option>
<option value="Miss">Miss</option>
<option value="Ms">Ms</option>
<option value="Dr">Dr</option>
</select>
</td>
</tr>
<td>
<label>
<input name="button" type="submit" id="button" value="Send" />
</label>
</td>
</tr>
</form>
Okay now the code I have in the sendemail php page:
<?php
$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$visitor = $_POST['visitor'];
$visitormail = $_POST['visitormail'];
$notes = $_POST['notes'];
$attn = $_POST['attn'];
if (eregi('http:', $notes)) {
die ("Please enter your message before you try submitting the form.");
}
if(isset($_POST['visitortitle'])) {$visitortitle = $_POST['visitortitle'];} else {$visitortitle = 'Nothing Selected';}
echo "<h2><br /><br /><br /><br />Please hit the back button and fill in your full name correctly<br />before you try submitting the form again.</h2>\n";
die ( '<a href="forum.html">click here go back and try again</a>' );
}
$from = "From: $visitor\r\n";
$message = " $todayis [EST] \n
Title: $visitortitle \n ";
mail("name@domain.com", $visitortitle);
?>
Re: Menu list sendmail .php
You still have an extraneous brace. If "Please hit the back button.." is supposed to display when $_POST['visitortitle'] is not set, you need to remove the brace after 'Nothing Selected'. Otherwise, you have an unmatched closing brace after die()
Re: Menu list sendmail .php
You didn't remove the brace:
EDIT: Celauran beat me to it. Damn.
Code: Select all
if(isset($_POST['visitortitle'])) {
$visitortitle = $_POST['visitortitle'];
} else {
$visitortitle = 'Nothing Selected';
} // This brace closes the else
echo "<h2>
Please hit the back button and fill in your full name correctly
before you try submitting the form again.</h2>\n";
die ( '<a href="forum.html">click here go back and try again</a>' );
} /* This brace does not close anything is causing your syntax error. Judging from your code,
this brace should stay put and you should remove the brace after you set $visitortitle = 'Nothing Selected' */
Re: Menu list sendmail .php
Thanks s92 but the problem I am still having is when I send the <option value=""></option> tag is not recognised as it doesn't pass if(isset
From my code any other suggestions?
Thanks
From my code any other suggestions?
Thanks
Re: Menu list sendmail .php
I've got no problems running it after taking out that brace...
Based on your form processing page, it looks like your form has a lot more to it than just the visitor type. Maybe the error lies somewhere in there?
Based on your form processing page, it looks like your form has a lot more to it than just the visitor type. Maybe the error lies somewhere in there?