View Full Version : i need some help on php

01-17-2010, 04:42 AM
Hi guys, i have a basic html knowledge and i dont know php at all. now i have a problem with my website where i want to make a simple order form,

For HTML part :
in a table prefix that contain,
Contact No.:
Mailing Address:
Postcode: State:
Item Code : <select><option>Item 1</option></select>

i hope to get this kind of format.

For php part :
i hope the php can read the html content and send a e-mail to my (order@domain.tld) so i can read the request and follow up with the buyer.
is it possible to make the e-mail send thru out using google app email instead of the webmail?

I hope someone could help me out, cause i got no idea how to make it and i dont mind u guys give me some example and abit of info on the code so i can learn it also.

a big thanks from me for thoose who help me and i will credit them on my forum :)

01-17-2010, 05:11 AM
There are approaches available for you to follow, but I don't believe that the actual 'mail' function in PHP supports third party applications.
That said, look into using the PEAR mailhandling classes. These should be more flexible and allow easy configurations for external hosts.
To do this otherwise, you'll want to open a tls socket to the gmail servers on port 465 (I think its 465, check with the gmail settings). So that would be something like this:

$errNo = -1;
$error = '';
$sock = fsockopen('tls://smtp.gmail.com', 465, $errNo, $error);

Fire you're email down it using fwrite, and it should work. That being said, I don't have a secure environment to test with, so I can't tell you for certain that this will work.

01-17-2010, 05:20 AM

PHP is good for submitting forms like this. HTML really has nothing to do with it. The extension of the page really does not matter either, as far as I know. forms that are submitted by the POST method I would assume are usually order forms, but I don't know this for certain. When you make an HTML form with controls on it, the method of the form is usually POST. You just basically need to reference the controls, and use MAIL() to send a follow up email to the buyer when they submit your form.

01-17-2010, 05:21 AM
hi thanks for the reply, but what about other part? i dont have any .html or .php file here, i need some example of the html and php. so i could try make some edit and learn.
thanks again


<form method="post" action="contact.php">
<table width="400" align=center bgcolor=#ffffff>
<tr><td width="150"><p>Division:</p></td><td width="250"><p><input type="checkbox" name="sendto" value="support@vivacenetwork.co.cc" checked="checked" />Support</input></p></td></tr>
<tr><td><p><font color=red>*</font> Name:</p></td><td><input size=30 name="Name"></td></tr>
<tr><td><p><font color=red>*</font> Contact No.:</p></td><td><input size=30 name="Contact No."></td></tr>
<tr><td><p><font color=red>*</font> Mailing Address:</p></td><td><textarea name="Mailing Address" rows=3 cols=30></textarea></td></tr>
<tr><td><p><font color=red>*</font> Email:</p></td><td><input size=30 name="Email"></td></tr>
<tr><td><p><font color=red>*</font> Item Code:</p></td><td><select><option>Item 1</option><option>Item 2</option></select>
<tr><td colspan=2 align=center><input type=submit name="send" value="Submit"> <input type=reset value="Reset" /></td></tr>
<tr><td colspan=2 align=center><p><small>A <font color=red>*</font> indicates a field is required</small></p></td></tr>

php part

$to = $_REQUEST['sendto'] ;
$from = $_REQUEST['Email'] ;
$name = $_REQUEST['Name'] ;
$headers = "From: $from";
$subject = "Website Support";

$fields = array();
$fields{"Name"} = "Name";
$fields{"Email"} = "Email";
$fields{"Message"} = "Message";

$body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }

$headers2 = "From: noreply@vivacenetwork.co.cc";
$subject2 = "Thank you for contacting us";
$autoreply = "Thank you for contacting us. Somebody will get back to you as soon as possible, usualy within 48 hours. If you have any more questions, please consult our forum at http://forum.vivacenetwork.co.cc";

if($from == '') {print "You have not entered an email, please go back and try again";}
else {
if($name == '') {print "You have not entered a name, please go back and try again";}
else {
$send = mail($to, $subject, $body, $headers);
$send2 = mail($from, $subject2, $autoreply, $headers2);
{header( "Location: http://vivacenetwork.co.cc/thankyou.htm" );}
{print "We encountered an error sending your mail, please notify support@vivacenetwork.co.cc"; }

i get this code at a website where it give tutorial how to make contact us, (sorry cant make credit cause i forget the site name)

i wanted to edit become a order such as i said on above, but the php part i dont know how to edit and make it can read the html content.