should be simple: PHP_SELF undefined index

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

jacquesy
New php-forum User
New php-forum User
Posts: 12
Joined: Tue Jan 21, 2003 2:27 pm

should be simple: PHP_SELF undefined index

Postby jacquesy » Tue Jan 21, 2003 2:48 pm

I'm a new PHP developer and am trying to develop my application using best practise programming techniques.

I am creating an admin area whereby I have a page to modify the contects of a table, I am using PHP_SELF when the new details are submitted but when I am submitting I recieve the following error:

PHP Notice: Undefined index: submit in C:\project\modifyman.php on line 53

I have tried and tried to sort this out but no joy, I would really appreciate somebodies help.

CODE:

<?php

//include connection to database
include "common_db.php";

//bring in database connection values
$Link;

//grabs the variable manufacturer from form
$manufacturer = "Null";

$submit = "false";

if ($submit=="false")
{

//query database
$Query = "SELECT dbManufacturerName FROM manufacturer";

//define what variable result
$Result = mysql_db_query ($DBName, $Query, $Link);

$self = $_SERVER['PHP_SELF'];

//create a form
print ("<font face='verdana' size='1'>");
print ("<form method='get' action='$self'>\n");
print ("<br>");
print ("Select a Manufacturer to modify:\n");
print ("<select name='manufacturer' style='font-family: verdana; font-size: 8pt'>\n");

//fetch the results from the database
while ($Row = mysql_fetch_array ($Result)) {
print ("<option value='$Row[dbManufacturerName]'>$Row[dbManufacturerName]\n");
}

//closes link to database
mysql_close($Link);

//completes html code
print ("</select>");
print ("<input type='submit' name='submit' value='true'>");
print ("</form>");
print ("</font>");
$submit = $_REQUEST["submit"];

}

if ($submit="true")

{

//displays current values in a form so that they can be edited

//grabs the variable manufacturer from above form
//$manufacturer = "Null";
//grabs the variable manufacturer from above form
$manufacturer = $_REQUEST["manufacturer"];

//print form header
print ("<font face='verdana'><h3>Modify $manufacturer:</h3>");
print ("<font face='verdana' size='1'>");

//include connection to database
include "common_db.php";

//bring in database values
$Link;

//query database
$Query = "SELECT * FROM manufacturer where dbManufacturerName = '$manufacturer'";

$Result = mysql_db_query ($DBName, $Query, $Link);

//Create a form

while ($Row = mysql_fetch_array ($Result)) {

print ("<form method=get action='modifyman.php4'>\n");
print ("<br>");

print ("Manufacturer Name:\n");
print ("<input type='text' name='manufacturer_name' maxlength='30' style='font-family: verdana; font-size: 8pt' value='$Row[dbManufacturerName]'><br>\n");


//complete html
print ("<br>");
print ("<input type='submit' style='font-family: verdana; font-size: 8pt' value='Update'>");
print ("</form>");
print ("<a href='navigation.php4'>Navigation Page</a>");
print ("</font>");
}
}

?>

User avatar
Redcircle
Moderator
Moderator
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA
Contact:

Postby Redcircle » Tue Jan 21, 2003 11:59 pm

$_REQUEST should actually be $_POST or $_GET

thus meaning $_REQUEST["submit"] is never initialized thus non existant.

User avatar
WiZARD
Moderator
Moderator
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol
Contact:

Re: should be simple: PHP_SELF undefined index

Postby WiZARD » Wed Jan 22, 2003 9:22 am

Hi!
Try chanche you 53 line from

Code: Select all

if ($submit="true")

at

Code: Select all

if ($submit=true)

but i'm do next:

Code: Select all

if (!$submit) {echo ("Sorry....")} else
{
// youre code here
............
}


Return to “PHP coding => General”

Who is online

Users browsing this forum: Baidu [Spider] and 0 guests