Solved

submit a form

Posted on 2004-10-18
2
284 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to count occurrences of each item in an array.
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 …

624 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