Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

I have adapted a php contact form of David Powers tut

Guest
Jul 07, 2007 Jul 07, 2007

Copy link to clipboard

Copied

Hi I have slowly changed according to my research etc. I am worried that since changing things that I have left some important error checking.
Well here is the error checking and the form:
<h2><span class="black">contact us : </span></h2>

<span class="errmsg1">
<?php
if ($error) {
echo 'Please complete the missing item(s) indicated.';
// remove escape characters from POST array
if (get_magic_quotes_gpc()) {
function stripslashes_deep($value) {
$value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
return $value;
}
$_POST = array_map('stripslashes_deep', $_POST);
}
}
?>
</span>
<form name="option" id="option" method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
<label> </label>
<table width="70%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>Your Name</td>
<td><input name="name" type="text" class="search" id="name" value="<?php if (isset($_POST['name'])) {
echo htmlentities($_POST['name']);} ?>" size="30" maxlength="50" /></td>
</tr>
<tr>
<td> </td>
<td><?php if (isset($error['name'])) { ?>
<span class="errmsg1"><?php echo $error['name']; ?></span>
<?php } ?> </td>
</tr>
<tr>
<td><span class="subheader">Your Email Address</span></td>
<td><span class="subheader">
<input name="email" type="text" id="email" value="<?php if (isset($_POST['email'])) {
echo htmlentities($_POST['email']);} ?>" size="30" maxlength="80" />
</span></td>
</tr>
<tr>
<td> </td>
<td><?php if (isset($error['email'])) { ?>
<span class="errmsg1"><?php echo $error['email']; ?></span>
<?php } ?> </td>
</tr>
<tr>
<td>Reason For Enquiry </td>
<td><label>
<select name="option">
<option value="">Please Select Option</option>
<option value="complaint"<?php
if (isset($error) && $_POST['option'] == 'complaint') { ?>
selected="selected"
<?php } ?>>Complaints</option>
<option value="listbusiness"<?php
if (isset($error) && $_POST['option'] == 'listbusiness') { ?>
selected="selected"
<?php } ?>>List My Business </option>
<option value="removelisting"<?php
if (isset($error) && $_POST['option'] == 'removelisting') { ?>
selected="selected"
<?php } ?>>Remove My Listing</option>
<option value="upgradelisting"<?php
if (isset($error) && $_POST['option'] == 'upgradelisting') { ?>
selected="selected"
<?php } ?>>Upgrade Listing</option>
<option value="banner"<?php
if (isset($error) && $_POST['option'] == 'banner') { ?>
selected="selected"
<?php } ?>>Banner Advertising</option>
<option value="agentenquiry"<?php
if (isset($error) && $_POST['option'] == 'agentenquiry') { ?>
selected="selected"
<?php } ?>>Become An Agent</option>
<option value="other"<?php
if (isset($error) && $_POST['option'] == 'other') { ?>
selected="selected"
<?php } ?>>Other</option>
</select>
</label></td>
</tr>
<tr>
<td> </td>
<td><?php if (isset($error['option'])) { ?>
<span class="errmsg1"><?php echo $error['option']; ?></span>
<?php } ?> </td>
</tr>
<tr>
<td>Message</td>
<td><label>
<textarea name="message" cols="30" rows="3" id="message"><?php if(isset($error)) {echo $messageBody;} ?>
</textarea>
</label></td>
</tr>
<tr>
<td> </td>
<td><?php if (isset($error['message'])) { ?>
<span class="errmsg1"><?php echo $error['message']; ?></span>
<?php } ?> </td>
</tr>
<tr>
<td> </td>
<td><label>
<input name="send" type="submit" class="searchbutton" id="send" value="Enquiry" />
</label></td>
</tr>
</table>
<label> </label>
<p><span class="subheader">
<label> </label>
</span></p>
</form>
TOPICS
Server side applications

Views

327
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 07, 2007 Jul 07, 2007

Copy link to clipboard

Copied

LATEST
jjjhbj111 wrote:
> Hi I have slowly changed according to my research etc. I am worried that since
> changing things that I have left some important error checking.

I haven't gone through your script with a fine-tooth comb, but your
email check uses a POSIX regular expression, which won't work with
preg_match(). You could use eregi() instead, but there are plans to
remove the ereg_ functions from PHP 6, so you would be better advised to
stick with Perl-compatible regular expressions (PCRE).

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines