Jump to content

Recommended Posts

Hi, 

 

I posted this already on another thread but I'll start my own just incase...

 

I have an html contact form that I'm trying to create a working php script for. 

I'm having a few difficulties... partly because I'm very new at this... well mostly because of that!  ;)

 

When I try to submit the contact form I get this error...

 

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home8/zomglawl/public_html/ericgruber.net/mailer.php on line 9

 

Parse error: syntax error, unexpected T_IF in /home8/zomglawl/public_html/ericgruber.net/mailer.php on line 10

 

Please be gentle because this is all new to me...  ;D

 

Here's the script...

 

<?php

if(isset($_POST["submit"])) {

 

$to = "you@yourdomain.net";

$subject = "Contact from website";

 

$name_field = $_POST[ "name"];

$email_field = $_POST[ "email"];

$city_field = $_POST[ "city"];

$state_field = $_POST[ "state"];

$phone_field = $_POST[ "phone"];

$message = $_POST[ "message"];

 

$body = "From: $name_field \n

E-Mail: $email_field \n

City: $city_field \n

State: $state_field \n

Phone: $phone_field \n 

Message:  Message: $message \n

 

";

 

echo "Data has been submitted to $to!";

mail($to, $subject, $body);

 

} else {

 

echo "blarg!";

 

}

?>

 

Here's my html form...

 

<form method="post" action="mailer.php">

        <table style="margin-bottom: 0pt;" cellspacing="0">

          <tbody>

            <tr>

              <td width="150">Name<span class="required"> *</span></td>

              <td><input name="Name" type="text"></td>

            </tr>

            <tr>

              <td>Email<span class="required"> *</span></td>

              <td><input name="Email" type="text"></td>

            </tr>

            <tr>

              <td>City</td>

              <td><input name="City" type="text"></td>

            </tr>

            <tr>

              <td>State</td>

              <td><input name="State" type="text"></td>

            </tr>

            <tr>

              <td>Phone<span class="required"> *</span></td>

              <td><input name="Phone" size="12"

maxlength="12" type="text"></td>

            </tr>

            <tr>

              <td>Comment<span class="required"> *<br>

              <br>

              <br>

              <br>

              <br>

              </span></td>

              <td><textarea name="Comment" cols="40"

rows="6"></textarea></td>

            </tr>

            <tr>

              <td><input name="Submit" value="Submit"

type="submit"></td>

              <td> </td>

            </tr>

          </tbody>

        </table>

      </form>

 

Thank you...

 

Link to comment
https://forums.phpfreaks.com/topic/145792-php-contact-form-help/
Share on other sites

addslashes may be turned off when posting/getting in your PHP config?

Try putting addslashes() round each of your posts and see what that does...

 

It should be turned off as it is being depreciated. Since he is not doing any db insert, this is how it should be.

 

Just so you know as an fyi.

Not sure if I left code out... I'm not completely sure what I'm doing wrong.  I'm using examples to create my own script... I may have missed something.  As far as uploading it to the wrong directory, I have it in the root directory with the html page.  Is that wrong? 

I like to use mysql_real_escape_string  ( $var ) to guarantee safety when sending things places.

He's not actually inserting anything into a database, as was pointed out to me before.

Why have you got them spaces in $_POST[" blah"]?

You could try taking them out, they're not supposed to be there.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.