Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

submit a form

Posted on 2004-10-18
2
Medium Priority
?
291 Views
Last Modified: 2006-11-17
Hi,

I have a form, but I don't know how to submit it using php. Is there a way to email the form? I tried using mailto:joe@doe.com but it emailed an empty message. Also, would this mailto: work even if the person was using webmail and did not set up an outlook account?

My webhosting has unlimited mysql, so if i need to create that to save the form into there, that would be fine. But I'd prefer to have it emailed to me (or any other way in which i would have easy access to the data). Thanks!

how would i fix the form to email it correctly?
or what php page would i need to create to save the form on mysql?

This is the code for my form:

<form action="mailto:rksprst@gmail.com" method="post" enctype="text/plain" name="form">
  <p>
    Name of item:
    <input name="name" type="text" id="name">
    Price: $
    <input name="price" type="text" id="price">
  </p>
  <p>Description of item:
    <textarea name="description" cols="70" rows="5" wrap="PHYSICAL" id="textarea"></textarea>
  </p>
  <p>Upload an image:
    <input name="image" type="file" id="image">
</p>
  <p>Email address:
    <input name="email" type="text" id="email">
 WE WILL NOT SEND YOU ANY JUNK EMAIL!</p>
  <p>
    <input name="private" type="radio" value="private">
    Keep my email address private. (BHJK.com will contact you on behalf of buyers)
    <input name="public" type="radio" value="public">
  I would like post my email address (Buyers will email me directly) </p>
  <p>&nbsp;</p>
  <p>How did you find out about us?
    <select name="selectt" size=1 onChange="">
<option value="">Choose One...

<!-- Option 1 -- To have the pull down menu go to your own pages, change the URL within the quotation marks and the link name.  -->
<!-- Option 2 -- You may remove or add entire lines to increase or decrease the number of links. -->
<option value="Other">Other
<option value="Newspaper">Newspaper
<option value="Poster/Flier">Poster/Flier
<option value="Search">Search
<option value="Friend">Friend

</select>
</p>
  <p>
    For security purposes please type in the numbers seen on this image: <img src="test.gif" width="78" height="20">    
    <input type="text" name="imagetest">
    </p>
  <p>&nbsp;</p>
  <p>
    <input type="checkbox" name="checkbox" value="checkbox">
    By checking this box I acknowledge that I have read and agreed to the Terms and Conditions which can be found here</p>
  <p>
    <input type="submit" name="Submit" value="Submit" > 
    <input type="reset" name="Submit2" value="Reset">
  </p>
</form>
0
Comment
Question by:rksprst
2 Comments
 
LVL 36

Accepted Solution

by:
Zyloch earned 1000 total points
ID: 12344058
Hi rksprst,

You would do this:

1) First make sure that you can use mail() function. Make a test PHP script with this:

<?php
if (mail("youremail@yahoo.com","Test","Works?")) {
   echo("Success!");
} else {
   echo("Failure :(");
}
?>

If it works, great! If it doesn't, post.

2) If it works, you would set the form action to $_SERVER['PHP_SELF'].

3) Then, for your code, at the top of this page, you would have PHP

<?php
if (isset($_POST['Submit'])) {
   if (mail("to@to.com","Subject","Message. Include variables here from form probably. Use \n for newline","From: from@from.com\r\nExtra headers: yep!\r\n")) {
      echo("Thank you!");
   } else {
      echo("Nope, there was a problem. Try again.");
   }
} else {
?>
<!--Rest of code-->
<?php
}
?>

Regards,
Zyloch
0
 
LVL 1

Author Comment

by:rksprst
ID: 12344132
Awesome.

Thanks  you!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses four methods for overlaying images in a container on a web page
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question