So I built my first working PHP "Contact Us" like form. But, I have been trying to now make the form Validate for empty fields when the user hits the submit button. Problem is when I added in the code and tried to mesh the two together it doesn't work. First I had errors and fixed those, but now I just get a blank white screen and an email doesn't send.
I will admit that this is my first time working with PHP and I don't have a full understanding yet. Needless to say, I can't seem to figure it out and just need some help.
Code: [Select]<?php
if ( $_POST['submit'] ) {
$error = '';
if ( $_POST['name'] == '' ) {
$error = 'Error: Please enter your name';
}
if ( $_POST['phonenumber'] == '' ) {
$error = 'Error: Please enter your phone number';
}
if ( $_POST['appointmentdate'] == '' ) {
$error = 'Error: Please enter a date';
}
if ( $_POST['appointmenttime'] == '' ) {
$error = 'Error: Please enter an appointment time';
}
if ( $_POST['appointmenttype'] == '' ) {
$error = 'Error: Please enter an appointment type';
}
if ( !$error ) {
$to = "bizsumpark182@gmail.com";
$subject = "Someone Has Requested An Appointment!";
$name_field = $_POST['name'];
$phonenumber_field = $_POST['phonenumber'];
$appointmentdate_field = $_POST['appointmentdate'];
$appointmenttime_field = $_POST['appointmenttime'];
$appointmenttype_field = $_POST['appointmenttype'];
$body = "From: $name_fieldn Phone Number: $phonenumber_fieldn Requested Appointment Date:n $appointmentdate_fieldn Requested Appointment Time:n $appointmenttime_fieldn Requested Appointment Type:n $appointmenttype_field";
if (mail($to, $subject, $body)) {
header("location: http://www.mathewballard.com/devriesdental/thankyou.html");
} else {
echo "Sorry, there was an error processing your request.";
}
}
}
?>
Code for Form:
Code: [Select]<div id="content2" align="left">
<?php if ( $error ) { ?>
<p class="error"><?=$error;?></p>
<?php } ?>
<form method="post" action="appointment.php" name="apptform">
<label for="name"><b>Name</b></label><br />
<input type="text" name="name" size="20" value="<?=$_POST['name'];?>" /><br /><br />
<label for="phonenumber"><b>Phone Number</b></label> (Starting with areacode)<br />
<input type="text" name="phonenumber" size="20" value="<?=$_POST['phonenumber'];?>" /><br /><br />
<label for="apptdate"><b>Appointment Date</b></label><br />
<input type="text" name="appointmentdate" size="20" value="<?=$_POST['appointmentdate'];?>" /><br /><br />
<label for="appttime"><b>Appointment Time</b></label><br />
<input type="text" name="appointmenttime" size="20" value="<?=$_POST['appointmenttime'];?>" /><br /><br />
<label for="appttype"><b>Apointment Type</b></label> (i.e. Annual Checkup, drilling, etc.)<br />
<textarea rows="10" name="appointmenttype" cols="30" ><?=$_POST['appointmenttype'];?></textarea><br /><br />
<input type="submit" value="submit" name="submit" /><br />
</form>
</div>
Convert .fdf to .pdf
I currently have a web form that uploads the form data to an .fdf file and emails it.However, I just realized that most people I email it to cannot open an .fdf and it needs to be in pdf.Is there any
Typing math
I've added support for typesetting math using LaTeX on the forums.Example:Code: [Select][tex]\sum_{n = 0}^\infty \frac{1}{n!} = \lim_{n\to\infty} \left(1+\frac{1}{n}\right)^n = e[/tex]Outputs:Just in
Inserting the current date/time while submitting the forum
What do I need to add below to update the current date/time? I have a field in the database called datetime. I tried to use Now() but its not working. Code: <?php$con =
Query output more than expected
$query=mysql_query("SELECT * FROM players, communities, divisions WHERE dob BETWEEN '{$start_date}' AND '{$end_date}' and communities.id=players.community order by communities.community,
problems with contact forms that are only protected against SQL injections
What could be a potential problem with contact forms that are only protected against SQL injections and have an admin side view for the enquiry ?
retrieving more than one max key from an array?
so i have an array of 20 numerical values (0-100) that i need to order from highest to lowest and then i need to retrieve the keys of the top ten values. $array1 =
why is it over writing
Code: $filepaths[] = $_FILES['new_image'];foreach ($filepaths as $filepath){$imagename = strtolower($filepath['name']);$charref = substr($imagename, 0, strrpos($imagename, '.'));
Calling variables
I want to call this to my website but it doesn't display what I want it to,Code: <h5>Edit Subject: <?php echo $sel_subject['menu_name']; ?></h5>If I change
Page not Loading After Test
Hey AllIt seemed that an inlcude statement wasn't working for some reason, so I tried a more absolute file path:include("home/username/public_html/coding/scripts/carspecs.php")However this
Line break?
Hi, I'm new to the forum and new to php. I'm not sure if I'm using the correct terminology so here it goes. I've created a page with multiple forms that when submitted get emailed to a certain