when submit is pressed should update then go to index page. but just getting blank page but it is updating
$dbh=mysql_connect("localhost", "xxxx", "xxxxx") or die('I cannot connect to database because: ' .mysql_error()) ;
// Get parameters from form.
mysql_query("update products set item='$item' where id='$id'");
$result=mysql_query("select * from products where id='$id'");
<!-- END OF PHP CODES AND START HTML TAGS -->
<!-- set this form to POST method and target this form to itself ($PHP_SELF;)-->
<form id="form1" name="form1" method="post" action="<? echo $PHP_SELF; ?>">
<input type="hidden" name="id" value="<?php echo $row['id']; ?>" />
<input name="item" type="text"size="100" id="item" value="<? echo $row['item']; ?>"/>
<p> <input type="submit" name="Submit" value="Submit" /> </p>
You can’t use header before you’ve output information.
Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include(), or require(), functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file.
Are you outputting information before the start of your <body> tag?
Error messages are very helpful when you’re writing code, because they often bring your attention to problems. You need to identify a problem before you can hope to fix it, and verbose error reporting can help with that. You should always configure php to show you errors while you’re developing and testing the code, although you shouldn’t display the errors on a live site.
Edit your php.ini file and set
display_errors = On
error_reporting = E_ALL | E_STRICT
Then restart your webserver. php should be very verbose now. Some of the messages aren’t due to serious issues, but they often reveal questionable parts of your code, which should probably be improved.
all sorted now
thnaks to all