Web Hosting Forum | Lunarpages


*
Welcome, Guest. Please login or register.
Did you miss your activation email?



Login with username, password and session length
May 24, 2012, 12:09:38 PM

Pages: [1]   Go Down
  Print  
Author Topic: Return from PHP to HTML form  (Read 4376 times)
jmcos0
Newbie
*
Offline Offline

Posts: 2


« on: March 16, 2011, 06:25:27 PM »

I have the following HTML form code:
   <form action="addvisitor.php" method="post">

When I submit my form, the PHP runs and updates my database, but I end up with a white screen with the echo text indicating the db was updated, but never end up back at my form.  The PHP file does not have a function, just the following (simplified):
  <?php
  $firstname = mysql_real_escape_string($_POST['first']);
  $lastname = mysql_real_escape_string($_POST['last']);
 
  $connected = mysql_connect(...);
  $select = mysql_select_db(...);
  echo(" Inserting " . $firstname . " " . $lastname . ".");
  mysql_query("INSERT INTO visitor (first_name, last_name)
              VALUES ('".$firstname."', '".$lastname."')
  ?>

I end up using the back arrow on the browser.  I'd like to go back to an empty form.  Any ideas?
Logged
wektech
Master Jedi
*****
Offline Offline

Posts: 1031



WWW
« Reply #1 on: March 17, 2011, 05:43:29 AM »

You will need to add some code such as
Code:
$gohere = "http://alldone.html";
header ("Location: $gohere");

Logged

jmcos0
Newbie
*
Offline Offline

Posts: 2


« Reply #2 on: March 17, 2011, 07:34:23 AM »

Thank you!  That SOLVED it.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to: