Solved

submit a form

Posted on 2004-10-18
2
280 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 250 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying 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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

809 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