Jump to content

Simple submit form button help ahhh! :)


dp69_2001

Recommended Posts

Anyways, I'm trying to get this submit form button to work. This is my first experience trying to alter PHP without direct instructions on what to do and type. My HTML and PHP for the form is below, or you can see it live at http://www.pricepcrepair.com/survey

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Price PC Repair Survey</title>

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

</head>

<form method="post" name= "myemailform" action="form-to-email.php">

 

<body>

<fieldset><legend>Your Contact Details</legend>

<p>

<label for="author">Name</label>

<input name="author" id="author" type="text" />

</p>

<p>

<label for="email">Email Address</label>

<input name="email" "id="email" type"text" />

</p>

<p>

<label for="location">Location</label>

<input name="location" id="location" type="text"/>

</p>

</fieldset>

<fieldset>

<legend>Are you a customer of Price PC Repair</legend>

<p>

<input id="customer-yes" class="radio" name="customer" type="radio" value="yes" />

    <label for="customer-yes">Yes</label>

</p>

<p>

<input id="customer-no" class="radio" name="customer" type="radio" value="no" />

<label for="customer-no">No</label>

</p>

<p>

 

<label for="text">If Yes, What can Price PC repair do to better serve it's customers? If No, Why not?</label>

<textarea name="text" id=text" cols="40" rows="5">

</textarea>

</fieldset>

</p>

<p>

<fieldset>

<legend>Do you think that you will be a customer during 2011?</legend>

<p>

<input id="future-yes" class="radio" name="future" type="radio" value="yes" />

    <label for="future-yes">Yes</label>

</p>

<p>

<input id="future-no" class="radio" name="future" type="radio" value="no" />

<label for="future-no">No</label>

</fieldset>

</p>

<p>

<fieldset id="website">

<h4>Have you ever used <a href="http://www.pricepcrepair.com/joomla/">PricePCRepair.com</a> to:</h4>

    </p>

    <div>

    <p>

    <input class="checkbox" id="schedule service" name="website" type="checkbox" value="schedule service" /> 

<label>Schedule Service?</label>

</p>

<p>

<input class="checkbox" id="help desk" name="website" type="checkbox" value="help desk" /> 

<label>Ask questions at the free help desk?</label>

</p>

<p>

<input class="checkbox" id="articles" name="website" type="checkbox" value="articles" /> 

<label>Read news, articles, and Reviews?</label>

</p>

<p>

<input class="checkbox" id="design" name="website" type="checkbox" value="design" /> 

<label>See images of past design work?</label>

</p>

<p>

</p>

</div>

<div>

<p>

<label for="text">Are there any features to <a href="http://www.pricepcrepair.com/joomla/">pricepcrepair.com</a> that you'd like to see implemented for 2011 to help better serve customers and potential clients?</label>

<textarea name="features" id=features" cols="40" rows="5">

</textarea>

</div>

<br class="clear" />

</fieldset>

</p>

<p>

<input type="submit" name="submit" value="Send Form">

</p>

 

 

 

</body>

</html>

 

</body>

</html>

 

 

and the PHP I have is

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<?php

  $name = $_POST['author'];

  $email = $_POST['email'];

  $location = $_POST['location'];

  $customer = $_POST['customer'];

  $text = $_POST['text'];

  $future = $_POST['future'];

  $website = $_POST['website'];

  $features = $_POST['features'];

$email_from = 'survey@pricepcrepair.com.com';

$email_subject = "New Form submission";

$email_body = "You have received a new message from the user $name.\n".

    "Here is the message:

\n $name

\n $email

\n $location

\n $customer

\n $text

\n $future

\n $website

\n $features

bool mail (string $dprice@pricepcrepair.com, string $subject, string $message, string $name, string $email, string $location, string $customer, string $text, string $future, string $website, string $features)

?>

Link to comment
Share on other sites

Learn how to write proper HTML.

 

The start of the form needs to be after the <body> tag not before it:

<body>
<form method="post" name= "myemailform" action="form-to-email.php">

 

And there is no closing </form> tag.

 

Not a PHP problem at all -- at least not now.

 

Ken

Link to comment
Share on other sites

Wow, I didn't even realize that I'd done that, I'd started adding the code for the button after the form was laid out and I suppose I got confused. Anyways, with that fixed still having the same error popping up.

 

Parse error: syntax error, unexpected $end in /home/content/64/4940664/html/form-to-email.php on line 27

Link to comment
Share on other sites

First you didn't mention what error you were getting in your first post, so I didn't even look at your PHP code.

 

When you get that error, it means that PHP got to the end of your file before a quoted string was finished or you have unmatched "{ }".

 

In your case you never closed the string for the variable $email_body.

 

But your code still isn't going to work, since the mail function call is wrong.

 

The mail function takes at most 5 parameters:

1) An email address to send the mail to, i.e. the "To:" address

2) A Subject

3) the Body

4) The headers (optional, but should be supplied (IMHO))

5) Additional headers that are send to the mail server (optional, but sometimes needed)

 

Ken

Link to comment
Share on other sites

Okay, I realized there was a . where there shouldn't have been, and then a " where there shouldn't have been, after some minor modifications I'm conflicting an error like this:

 

Parse error: syntax error, unexpected T_STRING in /home/content/64/4940664/html/form-to-email.php on line 26

and the current code is:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<?php

  $name = $_POST['author'];

  $email = $_POST['email'];

  $location = $_POST['location'];

  $customer = $_POST['customer'];

  $text = $_POST['text'];

  $future = $_POST['future'];

  $website = $_POST['website'];

  $features = $_POST['features'];

$email_from = 'survey@pricepcrepair.com.com';

  $email_subject = "New Form submission";

  $email_body = "You have received a new message from the user $name.\n

      Here is the message:

      \n $name

      \n $email

      \n $location

      \n $customer

      \n $text

      \n $future

      \n $website

      \n $features"

bool mail (string $dprice@pricepcrepair.com, string $subject, string $message, string $name, string $email, string $location, string $customer, string $text, string $future, string $website, string $features);

?>

 

Link to comment
Share on other sites

Ken, I understand that you are trying to help, and I greatly appreciate your time and assistance with this. However, I really don't understand when you just say that this and this are wrong. I know that it's wrong. I'm not a coder, I'd really love to learn php but at the present time the issue is getting my form working correctly. I think I've corrected the semi-colon thing but I can't be positive since that's not the error I'm receiving (and I've really never dealt with php, this is the first thing I've coded myself without specific documentation of what I have to do.) Anyways, the current code is

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
  $name = $_POST['author'];
  $email = $_POST['email'];
  $location = $_POST['location'];
  $customer = $_POST['customer'];
  $text = $_POST['text'];
  $future = $_POST['future'];
  $website = $_POST['website'];
  $features = $_POST['features'];
$email_from = 'survey@pricepcrepair.com.com';
   $email_subject = "New Form submission";
   $email_body = "You have received a new message from the user $name.\n
      Here is the message:
      \n $name;
      \n $email;
      \n $location;
      \n $customer;
      \n $text;
      \n $future;
      \n $website;
      \n $features;"
bool mail (string $dprice@pricepcrepair.com, string $subject, string $message, string $name, string $email, string $location, string $customer, string $text, string $future, string $website, string $features);
?>

 

(sorry, I didn't know it was supposed to be in tags) I'd actually be happy to reimburse whomever is able to help me understand this with a few dollars (not more than maybe $10 or $15) since it'd really be quite simple. I just have no knowledge of PHP, and am having trouble wrapping my brain around what it is exactly/specifically, I'm doing wrong. Still getting:

 

 

Parse error: syntax error, unexpected T_STRING in /home/content/64/4940664/html/form-to-email.php on line 26

 

Feel free to E-mail me at dp69_2001@msn.com With comments or suggestions that will be beneficial to figuring this out.

Link to comment
Share on other sites

google nl2br() php.....i dont think this is correct or is it your code to show it is in a new line?

 

CHANGE BELOW LINE:::

 

$email_body = "You have received a new message from the user $name.\n
      Here is the message:
      \n $name;
      \n $email;
      \n $location;
      \n $customer;
      \n $text;
      \n $future;
      \n $website;
      \n $features;"

 

TO:::

$email_body = nl2br("You have received a new message from the user $name.\n
      Here is the message:
      \n $name
      \n $email
      \n $location
      \n $customer
      \n $text
      \n $future
      \n $website
      \n $features");

 

 

Link to comment
Share on other sites

No, the nl2br function does not have to be used here. The OP wants to send a plain text email.

 

As to your error message, you need a semi-colon at the end of the block, after the last "

<?php
$email_body = "You have received a new message from the user $name.\n
      Here is the message:
      \n $name
      \n $email
      \n $location
      \n $customer
      \n $text
      \n $future
      \n $website
      \n $features";
?>

 

As for payment, we help here for free. If you want paid help, post in the freelancing area.

 

I recommend that you get familiar with the online PHP manual. It is actually very good with many user contributed examples. Also, there is W3 Schools.

 

When we give you a manual page to look at, we are pointing you to the section in the online manual that describes the function. Make sure you read it.

 

Ken

Link to comment
Share on other sites

Woot! Hey that manual was a big help! It's sending messages now and I figured out how to make it give them a message after submission! For some reason though, I'm not getting a subject or body in the E-mail. Current code looks like:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
  $name = $_POST['author'];
  $email = $_POST['email'];
  $location = $_POST['location'];
  $customer = $_POST['customer'];
  $text = $_POST['text'];
  $future = $_POST['future'];
  $website = $_POST['website'];
  $features = $_POST['features'];
$email_from = 'survey@pricepcrepair.com.com';
   $to = "dprice@pricepcrepair.com";
   $email_subject = "New Form submission from $name";
   $email_body = "You have received a new message from the user $name.\n
      Here is the message:
      \n $name
      \n $email
      \n $location
      \n $customer
      \n $text
      \n $future
      \n $website
      \n $features";
mail ($to,$subject,$message,$headers);
echo "Survey submitted, Thank you for your participation."
?>

 

You've really been a huge help, I'm digging through that manual trying to figure out how to make this work. Also, is there a way to add a link in the echo? Say like, Thank you for your participation! Return to http://www.pricepcrepair.com? or something similar?

Link to comment
Share on other sites

Holy crap! I'm a retard! lol. Anyway, it's working like a charm now with

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
  $name = $_POST['author'];
  $email = $_POST['email'];
  $location = $_POST['location'];
  $customer = $_POST['customer'];
  $text = $_POST['text'];
  $future = $_POST['future'];
  $website = $_POST['website'];
  $features = $_POST['features'];
$email_from = 'survey@pricepcrepair.com.com';
   $to = "dprice@pricepcrepair.com";
   $subject = "New Form submission from $name";
   $message = "You have received a new message from the user $name.\n
      Here is the message:
      \n $name
      \n $email
      \n $location
      \n $customer
      \n $text
      \n $future
      \n $website
      \n $features";
mail ($to,$subject,$message,$headers);
echo "Survey submitted, Thank you for your participation!"
?>

 

I still would like to figure out how to get the echo to show more, or maybe display/redirect to an html page if possible. Can someone explain that a little better or point me in the right direction to learn more about doing that? That would be epic.

Link to comment
Share on other sites

Figured that out, I wasn't too far off, I just needed to replace my html " 's with ' 's Thank you so much for your help ken. Couldn't have done it without ya. I do wonder if there's a way for it to tell me which value is which though. I doubt I'll go digging around for it though, really happy that I've gotten it this far. lol. Thank you so much for your time.

Link to comment
Share on other sites

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.