Help - Search - Members - Calendar
Full Version: So Simple Why Wont It Work
Zymic Webmaster Forums > Web Design & Development > Server Side Scripting > PHP
Mij
Hey folks,

Putting together a simple email responce form.... I think the code is pretty easy and for some reason it wont work.... please help....

CODE
<?php
if(isset($_POST['Submit'])) {
    $name = $_POST['name'];
    $email = $_POST['email'];
    $comments = $_POST['comments'];
    $mailing = $_POST['mailing'];
    if($name == '' or $email == '' or $comments == '') {
        $err = true;
        $msg = 'Please complete your name, email address and comments to submit the form.';
    } else {
        $mailmsg = 'The following email has been sent from the contact form:' . "\n\n";
        $mailmsg.= 'Name: ' . $name . "\n";
        $mailmsg.= 'Email: ' . $email . "\n";
        $mailmsg.= 'Comments: ' . $comments . "\n";
        if($mailing == 'true') {
            $mailmsg.= 'I would like to be added to the mailing list';
        }
        if (eregi("\r",$email) || eregi("\n",$email)){
            die ("spam!");

        } else {
            if(mail('jimwinfield@cox.net','Contact Form', $mailmsg, "From: noreply@example.com")) {
                header("Location: thankyou.html");
            }
        }
    }
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Contact Form</title>

<link href="styles.css" rel="stylesheet" type="text/css" />
</head>

<body>
<?php
if($err == true) {
    echo '<p class="error">'. $msg . '</p>';
}
?>
<form id="form1" method="post" action="contact.php">
  <div>
    <label for="name">Name</label>
    <input name="name" type="text" class="text" id="name" value="<?php echo $name; ?>" />
  </div>
   <div>
    <label for="email">Email address</label>
    <input name="email" type="text" class="text" id="email" value="<?php echo $email; ?>" />
  </div>
  
   <div>
     <label for="comments">Comments</label>
     <textarea name="comments" cols="30" rows="6" class="text" id="comments"><?php echo $comments; ?></textarea>
   </div>
  
   <div>
    
     <label for="mailing">Add me to your mailing list</label> <input type="checkbox" name="mailing" value="true" id="mailing" />
   </div>
   <div>
     <input name="Submit" type="submit" class="btn" value="Submit" />
   </div>
</form>


</body>
</html>


I tries testing the code My Website

Upon "submit"

it spits out this "Warning: mail() [function.mail]: SAFE MODE Restriction in effect. The mail() command is not allowed. in /www/vndv.com/j/i/m/jimbeingjim/htdocs/contact.php on line 22"

What should I do

Thanks Jim
harbino
I think the problem is with PHP safe mode been on. In that case there isn't much you can do... the only other thing I suggest you can do is try and find a different form.
Mij
QUOTE(harbino @ Aug 6 2008, 03:18 PM) *
I think the problem is with PHP safe mode been on. In that case there isn't much you can do... the only other thing I suggest you can do is try and find a different form.

Is there a way to turn off safe mode?
harbino
The only way is by asking Jack (the root admin).

It may include advancing a small fee to him. But you'd better check that it is safe mode causing the problem before trying to ask him.
Mij
QUOTE(harbino @ Aug 6 2008, 05:11 PM) *
The only way is by asking Jack (the root admin).

It may include advancing a small fee to him. But you'd better check that it is safe mode causing the problem before trying to ask him.

I c thx
Trippin7464
Just so you know, you can get safe mode turned off and php mail turned on for $15 bucks, or you can buy them seperately for $10 each. If you want to purchase, talk to Jack on zIRC
nitsuarox
QUOTE(Mij @ Aug 6 2008, 03:13 PM) *
Hey folks,

Putting together a simple email responce form.... I think the code is pretty easy and for some reason it wont work.... please help....

CODE
<?php
if(isset($_POST['Submit'])) {
    $name = $_POST['name'];
    $email = $_POST['email'];
    $comments = $_POST['comments'];
    $mailing = $_POST['mailing'];
    if($name == '' or $email == '' or $comments == '') {
        $err = true;
        $msg = 'Please complete your name, email address and comments to submit the form.';
    } else {
        $mailmsg = 'The following email has been sent from the contact form:' . "\n\n";
        $mailmsg.= 'Name: ' . $name . "\n";
        $mailmsg.= 'Email: ' . $email . "\n";
        $mailmsg.= 'Comments: ' . $comments . "\n";
        if($mailing == 'true') {
            $mailmsg.= 'I would like to be added to the mailing list';
        }
        if (eregi("\r",$email) || eregi("\n",$email)){
            die ("spam!");

        } else {
            if(mail('jimwinfield@cox.net','Contact Form', $mailmsg, "From: noreply@example.com")) {
                header("Location: thankyou.html");
            }
        }
    }
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Contact Form</title>

<link href="styles.css" rel="stylesheet" type="text/css" />
</head>

<body>
<?php
if($err == true) {
    echo '<p class="error">'. $msg . '</p>';
}
?>
<form id="form1" method="post" action="contact.php">
  <div>
    <label for="name">Name</label>
    <input name="name" type="text" class="text" id="name" value="<?php echo $name; ?>" />
  </div>
   <div>
    <label for="email">Email address</label>
    <input name="email" type="text" class="text" id="email" value="<?php echo $email; ?>" />
  </div>
  
   <div>
     <label for="comments">Comments</label>
     <textarea name="comments" cols="30" rows="6" class="text" id="comments"><?php echo $comments; ?></textarea>
   </div>
  
   <div>
    
     <label for="mailing">Add me to your mailing list</label> <input type="checkbox" name="mailing" value="true" id="mailing" />
   </div>
   <div>
     <input name="Submit" type="submit" class="btn" value="Submit" />
   </div>
</form>
</body>
</html>


I tries testing the code My Website

Upon "submit"

it spits out this "Warning: mail() [function.mail]: SAFE MODE Restriction in effect. The mail() command is not allowed. in /www/vndv.com/j/i/m/jimbeingjim/htdocs/contact.php on line 22"

What should I do

Thanks Jim


I don't if anyone else mentioned this but the mail() function is also disabled
Clew
if you don't want to pay, you can host that one page somewhere that does support mail() and just point your form to that page from your account here

in the form where your user puts the information in, theres a bit where you put your link to whatever page handles the form, that's the php script you posted. if you host that script somewhere else that provides free mail() and safe mode off, and just point to it from your site here, then it saves you some money.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.