LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-30-2004, 01:40 PM   #1
Savahn
Member
 
Registered: Mar 2003
Posts: 36

Rep: Reputation: 16
PHP and HTML Form Post


I am trying to get the FORM POST METHOD to work with a PHP script I have written. The script enters the data from the forms into a text file and emails the same data to a specific email address. When I access the webpage and enter my data then go and check the text file the only inside is the date... the same with the email that is sent. The linux server I running this script one is Slackware 10.0 with Apache 2 and the latest version of PHP. It acts as thou the form is not posting anything to the script but I know it is running the script. Please help!!!
 
Old 06-30-2004, 01:51 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
Perhaps it has been coded worng or it has been written to require that you have "register globals" set to "on" in your php configuration file.
 
Old 06-30-2004, 01:58 PM   #3
Savahn
Member
 
Registered: Mar 2003
Posts: 36

Original Poster
Rep: Reputation: 16
I have tried several different PHP scripts to include formmail. Global_registers is set to on and I have tried to set it to off as well. Same problem.
 
Old 06-30-2004, 02:01 PM   #4
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
Can you post a copy of what isn't working?
 
Old 06-30-2004, 02:03 PM   #5
Savahn
Member
 
Registered: Mar 2003
Posts: 36

Original Poster
Rep: Reputation: 16
Here is the PHP script. It worked before I rebuilt the current system and install Slackware 10 instead of Redhat 7.3.

<html>


<head>


<title></title>


</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">


<?






$space = "_______________";


$contact_db = fopen("contact.txt", "a");



$linevar = ereg_replace("<br>","n",$linevar);


$date = date("l, F dS, Y - h:i:s A");


fwrite($contact_db, $date."\r\n");


fwrite($contact_db, $space."\r\n\r\n");


// Edit the following coding


// replace textfield1 with the name of the first textfield on your email form
// Continue this process for textfield 2 through to 15


fwrite($contact_db, $firstname."\r\n");


fwrite($contact_db, $address."\r\n");


fwrite($contact_db, $city."\r\n");


fwrite($contact_db, $zipcode."\r\n");


fwrite($contact_db, $phone."\r\n");


fwrite($contact_db, $dialup."\r\n");


fwrite($contact_db, $cardtype."\r\n");


fwrite($contact_db, $cc."\r\n");


fwrite($contact_db, $exp1."\r\n");


fwrite($contact_db, $exp2."\r\n");


fwrite($contact_db, $total."\r\n");


fwrite($contact_db, $notes."\r\n\r\n");


fclose($contact_db);


// replace youremail@domain.com with the email you woudl like your form to submit to
// replace the Header titles with the headers you would like displayed in your email application
// replace the textfield variables wtih the names of the corresponding text fields on your form


mail("ADDEMAILADDRESS HERE", "Online Credit Card Payment", "Name on Card: $name\r\n\r\n Billing Address: $address\r\n\r\n City: $city\r\n\r\n Zip: $zipcode\r\n\r\n Home Number: $phone\r\n\r\n Dialup Account Number: $dialup\r\n\r\n Payment Type: $cardtype\r\n\r\n Credit Card #: $cc\r\n\r\n CC Expiration: $exp1, $exp2\r\n\r\n Amount to Charge Card: $total\r\n\r\n Notes and/or Addl Emails: $notes\r\n\r\n");


?>
<table width="760" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>
<table width="250" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td width="10"><img src="../../contact_form_submit/place_holder.gif" width="5" height="180"></td>
<td width="240" valign="top">
<div align="center"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><br>
<b><font color="#003366"><br>
<br>
<font size="2">Thank you!</font><br>
<br>
</font></b><font color="#003366">Your e-mail has been sent,
<br>
and the account will be credited in 1 - 2 business days.<br>
<br>
</font><font color=#ffffff face="Verdana, Arial, Helvetica, sans-serif"
size=2><b> </b></font></font>


<font size="1" face="Verdana, Arial, Helvetica, sans-serif"><font color="#003366"><br>
<br>

</font></font></div>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>


</td>
</tr>
</table>
</body>


</html>
 
Old 06-30-2004, 02:04 PM   #6
Savahn
Member
 
Registered: Mar 2003
Posts: 36

Original Poster
Rep: Reputation: 16
Here is the webpage.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<div align="center">
<form name="form1" method="post" action="submit.php">
<table width="75%" border="1">
<tr>
<td colspan="2"><div align="center"><strong></strong></div></td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td width="50%"><div align="right">Name (As it appears on card)<strong>
:</strong></div></td>
<td width="50%"><input type="text" name="firstname"></td>
</tr>
<tr>
<td><div align="right">Billing Address<strong> :</strong></div></td>
<td><input type="text" name="address"></td>
</tr>
<tr>
<td><div align="right">City <strong>:</strong></div></td>
<td><input type="text" name="city"></td>
</tr>
<tr>
<td><div align="right">Zip Code<strong> :</strong></div></td>
<td><input type="text" name="zipcode"></td>
</tr>
<tr>
<td><div align="right">Home Number<strong> :</strong></div></td>
<td><input name="phone" type="text" value="931-"></td>
</tr>
<tr>
<td><div align="right">Dial Up Access Number<strong> :</strong></div></td>
<td><select name="dialup" size="1">
<option value="563-4027">Coffee County 563-4027</option>
<option value="536-4027">Bedford County 536-4027</option>
<option value="386-4007">Franklin County 386-4007</option>
</select></td>
</tr>
<tr>
<td><div align="right">Payment Type<strong> :</strong></div></td>
<td><select name="cardtype" size="1">
<option value="Visa" selected>Visa</option>
<option value="Mastercard">Mastercard</option>
</select></td>
</tr>
<tr>
<td><div align="right">Credit Card Number<strong> :</strong></div></td>
<td><input type="text" name="cc"></td>
</tr>
<tr>
<td height="47">
<div align="right">Expiration Date<strong> :</strong></div></td>
<td><select name="exp1">
<option value="01" selected>01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
<select name="exp2" size="1">
<option value="04" selected>2004</option>
<option value="05">2005</option>
<option value="06">2006</option>
<option value="07">2007</option>
<option value="08">2008</option>
<option value="09">2009</option>
<option value="10">2010</option>
</select></td>
</tr>
<tr>
<td><div align="right">Amount to be charged<strong> :</strong></div></td>
<td><input type="text" name="total"></td>
</tr>
<tr>
<td colspan="2"><div align="center"><strong>Notes</strong></div></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<textarea name="notes" id="textarea"></textarea>
</div></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<p>
<input type="submit" name="Submit" value="Send">
</p>
</div></td>
</tr>
</table>
</form>
</div>
</body>
</html>
 
Old 06-30-2004, 02:13 PM   #7
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
Try using:
fwrite($contact_db, $_POST["firstname"]."\r\n");

Rather than:
fwrite($contact_db, $firstname."\r\n");

If it works for firstname then try it for the othe variables.
 
Old 06-30-2004, 02:31 PM   #8
Savahn
Member
 
Registered: Mar 2003
Posts: 36

Original Poster
Rep: Reputation: 16
That worked. Thanks for help.
 
Old 06-30-2004, 02:36 PM   #9
Savahn
Member
 
Registered: Mar 2003
Posts: 36

Original Poster
Rep: Reputation: 16
That did work for the contact.txt file but the email is still blank.
 
Old 06-30-2004, 02:37 PM   #10
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
You will need to replace the variable names there too. For instance $name becomes $_POST["name"]
 
Old 06-30-2004, 02:42 PM   #11
Savahn
Member
 
Registered: Mar 2003
Posts: 36

Original Poster
Rep: Reputation: 16
When I do that I get and error on the page saying

Parse error: parse error, unexpected '\"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/cc2/submit.php on line 91

Last edited by Savahn; 06-30-2004 at 02:44 PM.
 
Old 06-30-2004, 03:11 PM   #12
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
That is because you are surrounding the value in quotes too. Either use single quotes or:
".$_POST["name"]."

inplace of:
$name
 
Old 06-30-2004, 03:15 PM   #13
Savahn
Member
 
Registered: Mar 2003
Posts: 36

Original Poster
Rep: Reputation: 16
Thanks for help it works.

Last edited by Savahn; 06-30-2004 at 03:16 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP: html Form Select function problem camlinux Programming 2 05-15-2005 08:23 PM
is this php automatic form submit post wriiten correctly? fsock error.. verbatim Programming 1 05-11-2005 10:24 AM
PHP:Unable to post variables from html form to mysql database vikram_cvk Linux - Software 1 09-29-2004 03:01 PM
Post information not coming through PHP form. m3kgt Programming 5 04-02-2004 01:42 PM
Simple php script with html form not working. sinsoush Programming 4 04-01-2004 08:02 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:04 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration