By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,920 Members | 1,938 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,920 IT Pros & Developers. It's quick & easy.

Notice: Undefined Index on remote server but not in local testing.

P: 1
Notice: Undefined index: send in D:\Domains\workingdata.co.uk\wwwroot\contact_text. php on line 7

Hi,

I've started getting this error in the contact page form of my website. The web hosting company did an upgrade and it seems to coincide with that.

The Notice is at the top of the page, but the rest of the page displays normally and form still works. I don't get the Notice when I test the page on the local Apache server in the XAMPP installation.

I've checked that the variable is spelled the same throughout the code. I tried using 'submit' as the variable in the IF statement instead of 'send' and got the same Notice.

I'm still new to PHP. I don't understand which element of the code is causing the error, so I'm afraid I've pasted the lot in. It's an IF statement which asks if the send variable is there or not. If it is there, then the form's already been filled in and it displays a "thanks for your question" message, otherwise, if it's not there, it displays the form.

Thanks,

Franc.

[code]
<?php
// if the "submit" variable does not exit, the form has not been submitted, display initial page.

if (!$_POST['send'])
{
?>

<style type="text/css">
<!--
.style1 {color: #000000}
-->
</style>
<table width="620" align="center" cellpadding="0" cellspacing="0">

<tr>
<td width="620">
<h1 class="heading" align="left">We look forward to hearing from you
<img src="images/yellow dot.gif" height="1" width="330"></h1>
</td>
</tr>
<tr>
<td width="620" class="text">
You can contact us directly by filling out the contact form below.
Simply fill out your name, email address and your query, then click on submit.
We promise to get back to you within 24 working hours.
Alternatively, our contact details are listed at the foot of the page.
</td>
</tr>
<tr><td colspan="1" height="10"></td></tr>
<tr>
<td width="620">
<form class="products_table"action="contact.php" method="post">
<p class="body_text">Your name: <br><input type="text" name="user_name"></p>
<p class="body_text">Your email address: <br><input type="text" name="user_email"></p>
<p class="body_text">Your enquiry: <br><textarea name="user_enquiry" cols="60" rows="10"></textarea></p>
<p class="body_text"><input type="submit" value="submit" name="send"></p>
</form>
</td>
</tr>
<tr>
<td class="text" height="20">
</td>
</tr>
<tr><td height="10"><span class="text"><strong>If you would prefer </strong>, please contact us by one of the methods outlined below. </span></td>
</tr>
<tr><td>
<table width="620" cellpadding="0" cellspacing="0">
<tr><td height="20" colspan="2"></td></tr>
<tr>
<td width="70" colspan="1" valign="top" class="text style1">Post: </td>
<td class="text" colspan="1" width="548"><div align="left">
Working Data. <br>
24 Villiers Street, <br>
Leamington Spa, <br>
Warwickshire, <br>
United Kingdom. <br>
CV32 5YH.</div></td>
</tr>
<tr><td height="10" colspan="2"></td></tr>
<tr>
<td width="70" colspan="1" class="text style1">Tel/Fax: </td>
<td class="text" colspan="1" width="548">+44 (0) 1926 335 772</td>
</tr>
<tr><td height="10" colspan="2"></td></tr>
<tr>
<td width="70" colspan="1" class="text style1">Email: </td>
<td class="text" colspan="1" width="548"><a href="mailto:info@workingdata.co.uk">info@workingd ata.co.uk</a></td>
</tr>
<tr><td height="10" colspan="2"></td></tr>
</table>
</td></tr>

</table>

<?php
}
else
{
// if the submit variable exists, the form has been submitted.
// look for and process form data, display result.

$query_name=trim($_POST['user_name']);
$query_address=trim($_POST['user_email']);
$query_text=trim($_POST['user_enquiry']);

//echo "<p>Dear $query_name. Many thanks for your enquiry (detailed below). We will reply to $query_address with all haste</p>";
//echo "<p>$query_text</p>";
mail ("info@workingdata.co.uk","Contact Form Question",$query_text,"From: $query_address");
/*mail (query_address,"Working Data Enquiry Confirmation","Dear $query_name, This is an automated confirmation for the
enquiry you submitted. We will reply as soon as possible.","From: info@workingdata.co.uk");
*/
?>

<table width="620" align="center" cellpadding="0" cellspacing="0">
<tr><td>&nbsp;</td></tr>
<tr>
<td width="620">
<h1 class="heading" align="left"><u>Thank you very much indeed for your enquiry.</u></h1>
</td>
</tr>
<tr>
<td width="620">
<?php
echo "<p>Dear $query_name. Many thanks for your enquiry (detailed below). We will reply to $query_address within 24
working hours.</p><br>";
?>

</td>
</tr>
<tr><td><hr></td></tr>
<tr>
<td width="620">
<?php
echo "<p>$query_text</p>";
?>
</td>
</tr>
</table>
<?php
}
?>
[code]
Feb 4 '08 #1
Share this Question
Share on Google+
1 Reply


eragon
100+
P: 431
Welcome to TSDN. May i suggest changing your line

[PHP]if(!$_POST['send'])[/PHP]

to

[PHP]if(empty($_POST['send']))[/PHP]

The empty command is a more effective command that determines if a string is missing or does not exist.
Feb 4 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.