I use php on two seperate websites (and two different servers), and intend to use the same simple front end to allow me to add profiles.
With one server my code works fine, in the other I get the following error message:
Notice: Undefined variable: submit in C:\Inetpub\PHPTester\admin\add_profile_fe.php on line 9
This would appear to relate to the fact that I havn't declared any variables - the error is occuring when I hit the 'submit' button - I assume because I haven't declared the variable related to that button, $submit.
So two questions really:
WHy does this happen on one server and not the other (different versions of php possibly?)
How do I resolve the problem? Tried declaring the $submit variable but once it hasd a value it naturally ignores the form section.
Here's my code, if it helps. Thanks in advance to anyone who can help.
<html>
<head>
<title>xxx</title>
</head>
<body>
<?php
if ($submit) {
// process form
$db=mysql_connect ("xxx", "xxx", "xxx") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("xxx",$db);
$sql = "INSERT INTO tblxxx (title,date,heading,intro,story,contact,link,size,image,column,live) VALUES ('$title',now(),'$heading','$intro','$story','$contact','$link','$size','$image','$column','$live')";
$result = mysql_query($sql);
echo "Thank you! Your profile has been successfully entered.\n";
} else{
// display form
?>
<p><b><font size="2" face="Arial, Helvetica, sans-serif">Profile Entry</font></b></p>
<form method="post" action="<?php echo $PHP_SELF?>">
<table width="600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100">Title</td>
<td width="10"> </td>
<td><input type="Text" name="title" size="64"></td>
</tr>
<tr>
<td>Heading</td>
<td width="10"> </td>
<td><input type="Text" name="title" size="64"></td>
</tr>
<tr>
<td valign="top">Intro</td>
<td> </td>
<td><textarea rows="5" cols="50" name="intro"></textarea></td>
</tr>
<tr>
<td valign="top">Story</td>
<td> </td>
<td><textarea rows="20" cols="50" name="story"></textarea></td>
</tr>
<tr>
<td>Contact</td>
<td> </td>
<td><input type="Text" name="contact" size="30"></td>
</tr>
<tr>
<td>Link</td>
<td> </td>
<td><input type="Text" name="link" size="30"></td>
</tr>
<tr>
<td>Size (of PDF)</td>
<td> </td>
<td><input type="Text" name="size" size="30"></td>
</tr>
<tr>
<td>Image URL</td>
<td> </td>
<td><input type="Text" name="image" size="30"></td>
</tr>
<tr>
<td>Column</td>
<td> </td>
<td><input type="Text" name="column" size="30"></td>
</tr>
<tr>
<td>Live</td>
<td> </td>
<td><input type="Text" name="live" size="30"></td>
</tr>
<tr>
<td colspan="2"> </td>
<td> </td>
</tr>
<tr>
<td colspan="2"> </td>
<td><input type="Submit" name="submit" value="Add Profile"></td>
</tr>
</table>
</form>
<?php
} // end if
?>
</body>
</html>