473,324 Members | 2,179 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

First PHP script, need your help to debug

Hello,

I tested a PHP script with a FORM of 2 element and it delivered the
mail but then when I added more FORM elements, it failed to deliver.
Following is the content of the PHP script that I'm talking about, it
is my first PHP script. Please advise what's wrong. The mail server,
kind of unlikely, the first try it sent the mail (beginner's luck?),
all of sudden, it went down? it's not on my box.

Thanks.
<?php

$to_addr = 'd****@yahoo.com';

if (isset($_REQUEST['submit'])) {
$mail_body .= "WHYSELLING: ".$_REQUEST['WHYSELLING'];
$mail_body .= "\nHOUSEADDRESS: ".$_REQUEST['HOUSEADDRESS'];
$mail_body .= "\nLOANOUTSTANDING: ".$_REQUEST['LOANOUTSTANDING'];
mail($to_addr,'Form One');
print "Thank you for your submission.";
} else {
print<<<_HTML_
<form method="POST" action="$_SERVER[PHP_SELF]">
<table width="65%" border="4" cellpadding="2" cellspacing="0"
bgcolor="" align="center">
<tr><td>
<table border="0" cellspacing="0" cellpadding="0" bgcolor="">
<tr>
<td>Address of house you are selling:</td>
<td><font size="2" face="Arial">
<input name="HouseAddress" type="text" id="HouseAddress"
size="35">
</font></td>
</tr>
<tr>
<td>Why are you selling?</td>
<td><textarea name="WhySelling" cols="26" rows="3"
id="WhySelling"></textarea></td>
</tr>
<tr>
<td>Are there outstanding loans?</td>
<td><font size="2" face="Arial">
<input type="radio" value="Yes" name="LoanOutstanding">
Yes
<input type="radio" name="LoanOutstanding" value="No">
No</font></td>
</tr>

<p align="center">
<input TYPE="submit" NAME="submit" VALUE="Send Form">
</td>
</tr>
</table>

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

</form>
_HTML_;
}

?>
Jul 17 '05 #1
2 1962
In article <9a**************************@posting.google.com >,
do***@yahoo.com (DonLi) wrote:
Hello,

I tested a PHP script with a FORM of 2 element and it delivered the
mail but then when I added more FORM elements, it failed to deliver.
Following is the content of the PHP script that I'm talking about, it
is my first PHP script. Please advise what's wrong. The mail server,
kind of unlikely, the first try it sent the mail (beginner's luck?),
all of sudden, it went down? it's not on my box.

Thanks.
<?php

$to_addr = 'do***@yahoo.com';

if (isset($_REQUEST['submit'])) {
$mail_body .= "WHYSELLING: ".$_REQUEST['WHYSELLING'];
$mail_body .= "\nHOUSEADDRESS: ".$_REQUEST['HOUSEADDRESS'];
$mail_body .= "\nLOANOUTSTANDING: ".$_REQUEST['LOANOUTSTANDING'];
Variable names are case sensitive. $_REQUEST['WHYSELLING']*and
$_REQUEST['whyselling'] isn't the same variable.
mail($to_addr,'Form One');
You didn't include the third required argument to mail() - the actual message
to send. Presumably, you want something like:

$msg = "
Why he is selling: $_REQUEST[whyselling]
The address: $_REQUEST[houseaddress]
Loans outstanding: $_REQUEST[loadoutstanding]
";
mail($to_addr, "A subject line", $msg);

print "Thank you for your submission.";
} else {
print<<<_HTML_
<form method="POST" action="$_SERVER[PHP_SELF]">
<table width="65%" border="4" cellpadding="2" cellspacing="0"
bgcolor="" align="center">
<tr><td>
<table border="0" cellspacing="0" cellpadding="0" bgcolor="">
<tr>
<td>Address of house you are selling:</td>
<td><font size="2" face="Arial">
<input name="HouseAddress" type="text" id="HouseAddress"
size="35">
</font></td>
</tr>
<tr>
<td>Why are you selling?</td>
<td><textarea name="WhySelling" cols="26" rows="3"
id="WhySelling"></textarea></td>
</tr>
<tr>
<td>Are there outstanding loans?</td>
<td><font size="2" face="Arial">
<input type="radio" value="Yes" name="LoanOutstanding">
Yes
<input type="radio" name="LoanOutstanding" value="No">
No</font></td>
</tr>

<p align="center">
<input TYPE="submit" NAME="submit" VALUE="Send Form">
</td>
</tr>
</table>

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

</form>
_HTML_;
}

?>


--
Sandman[.net]
Jul 17 '05 #2
DonLi wrote:
<?php

$to_addr = 'd****@yahoo.com';

if (isset($_REQUEST['submit'])) {
$mail_body .= "WHYSELLING: ".$_REQUEST['WHYSELLING'];
$mail_body .= "\nHOUSEADDRESS: ".$_REQUEST['HOUSEADDRESS'];
$mail_body .= "\nLOANOUTSTANDING: ".$_REQUEST['LOANOUTSTANDING'];
mail($to_addr,'Form One');
You need to put $mail_body in the mail() call
mail($to_addr, 'Form one', $mail_body);
print "Thank you for your submission.";
} else { (snip) }

?>


But PHP should have complained about that.
Have you changed the error_reporting level?
Put

error_reporting(E_ALL);

at the top of every script you make to see all errors, warnings and
notices in the browser.
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: John | last post by:
Hello. If I want to set up my first database and start using it in Dreamweaver what do I need to do? The book I'm working on has a CD with the database on. It is telling me to put it in the...
5
by: deko | last post by:
In regard to running php scripts with cron - Here is a sample script: <?php //debug.php echo "<br> This is a test"; ?> I can call debug.php from a web page on my site like this:
7
by: Chris | last post by:
Hello, I posted a while back about a newbie database question and got a lot of great help here. My script that I am creating has come a long way (For me!) and almost does what I need it too. I...
36
by: Cap'n Ahab | last post by:
I have used VB3 - VB6, so learning all this OO stuff is reasonably new to me (although I looked at Java a few years ago). Anyway, I thought I would write a small class to begin with, with a...
0
by: hagar | last post by:
Hi all, I have a problem which I can not understand why this is happening! Debugging this I actually see that it grabs first record then when stepping through code to the line rsImportTo.AddNew...
0
by: Bev | last post by:
Hello :-), I am not sure if I am in the right forum so please forgive me if I err. My Ops is XPPro, SP2 installed, IE6 and Outlook Express6, Office 2002. I am using ready made scripts in htm...
3
by: nuchphasu | last post by:
Hi I have a problem on Dropdownlist that connect database and retrieve data by Ajax.I write javascript like this -------------------------------------------------------------------------...
4
by: dbee | last post by:
Right. I've got a really, really annoying/difficult/time consuming problem with my development environment. I'm using django to build a web app with paypal integration. My server is hosted...
4
by: Chris8Boyd | last post by:
I am embedding Python in a MSVC++ (2005) application. The application creates some environment and then launches a Python script that will call some functions exported from the MSVC++ application....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.