473,406 Members | 2,208 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,406 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 1972
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.