HTML Tutorial


 /help/HTML Help Forum   FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
RegisterRegister - Not registered yet? Got something to say? Join HTML Code Tutorial!
form to database sending problmes
Post new topic   Reply to topic    HTML Help Forum -> Javascript
View previous topic :: View next topic  
Author Message
legohead6



Joined: 23 Feb 2006
Posts: 39

PostPosted: Thu Mar 30, 2006 7:46 pm     form to database sending problmes Reply with quote

ok..i want this form to only send when the user clicks submit...right know it sends whenever a user enters or refreshes the page! heres the code!

Code:
$first=$_POST['first'];
$last=$_POST['last'];
$gun=$_POST['gun'];
$age=$_POST['age'];
$saying=$_POST['saying'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$users=$_POST['user'];
$passs=$_POST['pass'];

// open connection
$connection = mysql_connect($host, $user,'--) or die ("Unable to
connect!");

// select database
mysql_select_db($db) or die ("Unable to select database!");

$query = "INSERT INTO members VALUES ('$first','$last','$gun','$age','$saying','$email','$phone','$users','$passs')";
mysql_query($query);
?></p>

<p align="center">Player Info form!</p>
<form method="POST" name="membership" action="Membership.php">
  <p align="center">First name <input type="text" name="first" size="20">
  Last Name:<input type="text" name="last" size="24">
  <br><br>
  Phone#<input type="text" name="phone">(format= 000-0000)
  <p align="center">
  Gun type:<input type="text" name="gun" size="36"><br>
  <br>
  Age:<input type="text" name="age" size="3"><br>
  <br>
  Saying:<br>
  <textarea rows="2" name="saying" cols="20"></textarea></p>
  <p align="center">
  Current email address:<input type="text" name="email" size="36">
  &nbsp;</p>
  <p align="center">
  Desired Username:<input type="text" name="user" size="20">
  &nbsp;</p>
  <p align="center">
  Desired pass:<input type="password" name="pass" size="20">
  </p>
  <p align="center"><input type="submit" value="Submit" name="B1"></p>
</form>
&nbsp;</body>
degsy



Joined: 23 Feb 2005
Posts: 2440
Location: North East, UK

PostPosted: Sat Apr 01, 2006 5:45 am     Reply with quote

Use an if statement to check if the form has been submitted.

if(isset($_POST)){

if(isset($_POST['Submit'])){ // check for a submit button called 'Submit'
Display posts from previous:   
Post new topic   Reply to topic    HTML Help Forum -> Javascript All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
HTML Help Archive
Powered by phpBB © 2001, 2005 phpBB Group
HTML Help topic RSS feed 

 
DARFUR
HOSTING / DESIGN
MAKE MONEY

Home
  |   Tutorials   |   Forum   |   Quick List   |   Link Directory   |   About
Copyright ©1997-2002 Idocs and ©2002-2007 HTML Code Tutorial