Be seen. Boost your question’s priority for more expert views and faster solutions
html:
<form method="post" action="sendmail.php"><br>
<table width="580" border="0" align="center">
<tr>
<td width="296"><div align="right">Name:</div></td>
<td width="268"><div align="left">
<input name="name" type="text" /></td
></tr>
<tr>
<td><div align="right">Email Address:</div></td>
<td><div align="left"><input name="email" type="text" /></td>
</tr>
<tr>
<td><div align="right">ISS Username (if known):</div></td>
<td><div align="left"><input name="username" type="text" /></td>
</tr>
<tr>
<td><div align="right">Telephone Number:</div></td>
<td><div align="left"><input name="phone" type="text" /></td>
</tr>
<tr>
<td><div align="right">Location (e.g room number):</div></td>
<td><div align="left"><input name="location" type="text" /></td>
</tr>
<tr>
<td><div align="right">Please provide details of the problem, or leave any message here.<br>
<br>
Press 'submit' when done.</div></td>
<td><div align="left"><textarea name="message" rows="10" cols="40"></textarea></td>
</tr>
</table><br>
<input type="submit" VALUE="Submit" align="right"/><br>
</form>
Php:
<?php
$email = $_REQUEST['email'] ;
$name = $_REQUEST['name'] ;
$username = $_REQUEST['username'] ;
$phone = $_REQUEST['phone'] ;
$location = $_REQUEST['location'] ;
$message = $_REQUEST['message'] ;
$message .= "\nUsername****:$username\n";
$message .= "\nContact Number****:$phone\n";
$message .= "\nEmail Address****:$email\n";
$message .= "\nLocation Details****:$location\n";
mail( "sample@leeds.ac.uk", "New helpdesk email", $message, "From: $name <$email>" );
header( "Location: http://www.leeds.ac.uk/iss/contact_test/thankyou.html" );
?>
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST') {
$errors = 0;
$email = $_REQUEST['email'] ;
$name = $_REQUEST['name'] ;
$username = $_REQUEST['username'] ;
$phone = $_REQUEST['phone'] ;
$location = $_REQUEST['location'] ;
$description = $_REQUEST['description'];
if(empty($email)) {
$errors++; //
echo '<div>Please make sure you fill out the email field correctly</div>';
}
if(empty($description)) {
$errors++; //
echo '<div>Please make sure you fill out the problem description field correctly</div>';
}
if($errors == 0) {
$message = $_REQUEST['message'] ;
$message .= "\nUsername****:$username\n";
$message .= "\nContact Number****:$phone\n";
$message .= "\nEmail Address****:$email\n";
$message .= "\nLocation Details****:$location\n";
mail( "sample@leeds.ac.uk", "New helpdesk email: $description", $message, "From: $name <$email>" );
header( "Location: http://www.leeds.ac.uk/iss/contact_test/thankyou.html" );
}
}
?>
<form method="post" action="sendmail.php"><br>
<table width="580" border="0" align="center">
<tr>
<td width="296"><div align="right">Name:</div></td>
<td width="268"><div align="left">
<input name="name" type="text" value="<?php echo htmlspecialchars(@$_REQUEST['name']);?>" /></td
></tr>
<tr>
<td><div align="right">Email Address:</div></td>
<td><div align="left"><input name="email" type="text" value="<?php echo htmlspecialchars(@$_REQUEST['email']);?>"/></td>
</tr>
<tr>
<td><div align="right">ISS Username (if known):</div></td>
<td><div align="left"><input name="username" type="text" value="<?php echo htmlspecialchars(@$_REQUEST['username']);?>"/></td>
</tr>
<tr>
<td><div align="right">Telephone Number:</div></td>
<td><div align="left"><input name="phone" type="text" value="<?php echo htmlspecialchars(@$_REQUEST['phone']);?>"/></td>
</tr>
<tr>
<td><div align="right">Location (e.g room number):</div></td>
<td><div align="left"><input name="location" type="text" value="<?php echo htmlspecialchars(@$_REQUEST['location']);?>"/></td>
</tr>
<tr>
<td><div align="right">Short problem description:</div></td>
<td><div align="left"><input name="description" type="text" value="<?php echo htmlspecialchars(@$_REQUEST['description']);?>"/></td>
</tr>
<tr>
<td><div align="right">Please provide details of the problem, or leave any message here.<br>
<br>
Press 'submit' when done.</div></td>
<td><div align="left"><textarea name="message" rows="10" cols="40" ><?php echo htmlspecialchars(@$_REQUEST['message']);?></textarea></td>
</tr>
</table><br>
<input type="submit" VALUE="Submit" align="right"/><br>
</form>
<script>
function checkForm(f) {
if (f.name.value == '' && f.email.value == '' && f.phone.value == '' ...) {
alert('please fillout at least on field');
return false;
}
return true;
}
</script>
<form method="post" action="sendmail.php" onsubmit="return checkForm(this);">
sendmail.php:
<?php
$email = $_REQUEST['email'] ;
$description = $_REQUEST['description'] ;
$name = $_REQUEST['name'] ;
$username = $_REQUEST['username'] ;
$phone = $_REQUEST['phone'] ;
$summary = $_REQUEST['summary'] ;
if(empty($email)) {
$errors++; //
echo '<div>Please make sure you fill out the email field correctly</div>';
}
if(empty($description)) {
$errors++; //
echo '<div>Please make sure you fill out the problem description field correctly</div>';
}
if($errors == 0)
$message = $_REQUEST['message'] ;
$message .= "\nUsername****:$username\n";
$message .= "\nContact Number****:$phone\n";
$message .= "\nEmail Address****:$email\n";
mail( "helpdesk@leeds.ac.uk", $_REQUEST['summary'], $message, "From: $name <$email>" );
header( "Location: http://www.leeds.ac.uk/iss/contact_test/thankyou.html" );
}
?>
- - - - - - - - - - - - -
<form method="post" action="sendmail.php" onsubmit="return checkForm(this);">
<form method="post" action="sendmail.php"><br>
<table width="580" border="0" align="center">
<tr>
<td width="296"><div align="right">Name:</div></td>
<td width="268"><div align="left">
<input name="name" type="text" /></td
></tr>
<tr>
<td><div align="right">Email Address:</div></td>
<td><div align="left"><input name="email" type="text" /></td>
</tr>
<tr>
<td><div align="right">ISS Username (if known):</div></td>
<td><div align="left"><input name="username" type="text" /></td>
</tr>
<tr>
<td><div align="right">Telephone Number:</div></td>
<td><div align="left"><input name="phone" type="text" /></td>
</tr>
<tr>
<td><div align="right">Subject:</div></td>
<td><div align="left"><input name="subject" type="text" /></td>
</tr>
<tr>
<td><div align="right">Please provide details of the problem, or leave any message here.<br>
<br>
Press 'submit' when done.</div></td>
<td><div align="left"><textarea name="message" rows="10" cols="40"></textarea></td>
</tr>
</table><br>
<input type="submit" VALUE="Submit" align="right"/><br>
</form>
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
From novice to tech pro — start learning today.
if($errors == 0)
is not
if($errors == 0) {
opening barce missing.