I have a Centos box running a site of mine, and I'm fiddling with passing variables - to the same page: index.php
I have a simple form and a mysql insert script, but on the same page. when I check my error_log file I see this:
Undefined index: newin /var/www/html/mysite.com on line 4
AND
Undefined index: newdomain in /var/www/html/mysite.com on line 4
I'm confused why I am getting this, when I am using an if() statement in the top. I can do all this with 2 pages, one page for the form, and the other for executing the insert statement, but I'd like to have it on one page. So, is there a way to stop the error in the logs?
Below is the code:
<?
require('includes/configure.php');
if($_GET['newdomain']) {
$sql = "INSERT INTO checklist(step,desc)
VALUES (
'$_POST[step]',
'$_POST[desc]'
)
";
$result = mysql_query($sql,$connection);
}
?>
<html>
<head>
<title>Passing variables</title>
</head>
<body>
<table width="100%" border="1" cellpadding="0" cellspacing="0">
<tr>
<td align="center"><a href="index.php?new=1">Insert new item</a></td>
</tr>
<? if($_GET['new'] == 1) { ?>
<tr>
<td></td>
<td><form action="index.php" method="post" name="newstep">
<input class="textbox" name="newdomain" type="hidden" id="newdomain" >
<input class="textbox" name="step" type="text" id="step" size="53"><br>
<textarea name="desc" cols="40" rows="4" class="textbox" id="desc"></textarea>
<input class="textbox" type="submit" name="Submit" value="insert">
</form></td>
</tr>
<? } ?>
</td>
</tr>
</table>
</body>
</html>