Code error or something more sinister...

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Grandaddy_Low
New php-forum User
New php-forum User
Posts: 2
Joined: Thu Mar 06, 2003 7:02 am

Code error or something more sinister...

Postby Grandaddy_Low » Thu Mar 06, 2003 7:17 am

Hello All,

I am fairly new to PHP and have not come accross this before... Just trying to write a simple form to update a database at the moment, but its having none of it. When run, the code displays the form, but refuses to run the 'then' section of the code, which would update the database (but is simply echoing to screen ATM. The screen simply remains stuck on the form. Would be gratefull if someone could advise where I am coming undone... Here is the code - sorry about the large post...

Cheers, G.

[size=9]

Code: Select all

<?php

If($submit)
  // process form data
  {
  echo "in then";
  while (list($name, $value) = each($HTTP_POST_VARS)) {
    echo "$name = $value<br>\n"; }
  }

else
  {
  //display form
  echo "Submit: ";
  echo $submit;
  ?>
  <form method="POST" action="<?PHP echo $PHP_SELF?>" >
  Movie title: <input type="Text" name="movie" value="movie"><br>
  Movie comments: <input type="Text" name="comments" value="comments"><br>
  <input type="submit" name="submit" value="Enter">
  <input type="reset">
  </form>
  <?php
  }
  ?>

p3x
New php-forum User
New php-forum User
Posts: 17
Joined: Mon Mar 03, 2003 10:53 am

Postby p3x » Thu Mar 06, 2003 8:12 am

Im a newbie too :) *shakes hands* - I have had similar problems though. You might try it this way:

<?php
$submit = $_POST['submit'];
if (isset($submit)) {
echo "im here!";
}
?>

Make SURE that you have the correct name for the submit button in the input field of your form, so like this:

<INPUT TYPE="submit" NAME="submit" VALUE="send!">

Even caps can make a difference I think :) so check that as well. I hope it helps! :) good luck, lemme know

P3x


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 3 guests

cron