Log in

View Full Version : Trying to echo and submit a form



revray
02-24-2008, 05:43 AM
Evening,

I am trying to echo a form that is listed below, the form appears in my page, but when I press submit, nothing happens. Can anyone give me guidance on what step I am missing?


//below this is the function for no record!!
if (!$variable1)
{
echo "<p> Great news! Jeff is available. Please fill out the form below to contact Jeff about booking your date. Please note, your date IS NOT booked yet, it simply is available. Make sure to fill out this form so Jeff can get back to you.</p>";

echo('<form action="http://formmail.dreamhost.com/cgi-bin/formmail.cgi" method="POST">');
echo('<input type="hidden" name="recipient" value="pray@wburgnaz.com"><br>');
echo('<input type="hidden" name="subject" value="Wedding Booking Inquiry"></p><br>');
echo(' <p>Full Name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="text" size="20" name="name" ></p><br>');
echo(' <p>Phone Number: <input type="text" size="20" name="phone"></p><br>');
echo(' <p>Email Address: <input type="text" size="20" name="email"></p><br>');
echo(' <p>Wedding Date: <input type="text" size="20" name="weddate"></p><br>');
echo(' <p><input name="Submit" type="button" value="Submit" class="button" /></p>');
echo('</form>');



}
//end
?>

magik
02-24-2008, 06:19 AM
Where is the <?php ?
You also have to remember that you cannot use " without putting a \ in front of it. You also need to close off your echo statements with a ;
Try the following code:


<?php
//below this is the function for no record!!
if (!$variable1)
{
echo "<p>Great news! Jeff is available. Please fill out the form below to contact Jeff about booking your date. Please note, your date IS NOT booked yet, it simply is available. Make sure to fill out this form so Jeff can get back to you.</p>";

echo "<form action=\"http://formmail.dreamhost.com/cgi-bin/formmail.cgi\" method=\"POST\">";
echo "<input type=\"hidden\" name=\"recipient\" value=\"pray@wburgnaz.com\"><br>";
echo "<input type=\"hidden\" name=\"subject\" value=\"Wedding Booking Inquiry\"></p><br>";
echo "<p>Full Name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type=\"text\" size=\"20\" name=\"name\" ></p><br>";
echo "<p>Phone Number: <input type=\"text\" size=\"20\" name=\"phone\"></p><br>";
echo "<p>Email Address: <input type=\"text\" size=\"20\" name=\"email\"></p><br>";
echo "<p>Wedding Date: <input type="text" size=\"20\" name=\"weddate\"></p><br>";
echo "<p><input name=\"Submit\" type=\"button\" value=\"Submit\" class=\"button\" /></p>";
echo "</form>";
}
//end
?>


An even better way to do it is to stay away from using html inside php example:


<?php
//below this is the function for no record!!
if (!$variable1)
{
?>
<p>Great news! Jeff is available. Please fill out the form below to contact Jeff about booking your date. Please note, your date IS NOT booked yet, it simply is available. Make sure to fill out this form so Jeff can get back to you.</p>

<form action="http://formmail.dreamhost.com/cgi-bin/formmail.cgi" method="POST">
<input type="hidden" name="recipient" value="pray@wburgnaz.com"><br>
<input type="hidden" name="subject" value="Wedding Booking Inquiry"></p><br>
<p>Full Name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="text" size="20" name="name" ></p><br>
<p>Phone Number: <input type="text" size="20" name="phone"></p><br>
<p>Email Address: <input type="text" size="20" name="email"></p><br>
<p>Wedding Date: <input type="text" size="20" name="weddate"></p><br>
<p><input name="Submit" type="button" value="Submit" class="button" /></p>
</form>
<?php
}
//end
?>

alexjewell
02-25-2008, 12:28 AM
Go with the latter example given above...the backslashes just get too crazy when there's that much code. When there's small amounts of code, switch to single quotes around the code...doing so means no backslashes:



echo '<p class="awesome">Awesome "Quotes!"</p>';

Nile
02-25-2008, 12:54 AM
@magik
Your wrong, hes using single quotes, so it wouldn'y matter, he would need to put 'em before a ' not a ".

revray
02-25-2008, 01:55 AM
Thanks so much for the help, I appreciate it, got it working!!