Solved

submit a form

Posted on 2004-10-18
2
277 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

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.  …
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

759 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now