ok...

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Faith
Forum Newbie
Posts: 7
Joined: Sun Mar 14, 2004 10:30 pm

ok...

Post by Faith »

Well thanks for the script... i will try it, and as for what my script is... here it is.....

display.php

Code: Select all

<form action="register.php" method="post">
<table>
<tr>
<td>Name</td>
<td><input type="textfield" name="txtName"></td>
</tr>

<tr>
<td>Password</td>
<td><input type="password" name="txtPassword"></td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="Register">
</td>
</tr>
</table>
</form>
register.php

Code: Select all

<?php 

$dbh=mysql_connect ("localhost", "equestra_test", "password") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("equestra_members");

$username = $HTTP_POST_VARS&#1111;'txtName'];
$password = $HTTP_POST_VARS&#1111;'txtPassword'];

$rs = mysql_query("SELECT * FROM myUsers WHERE Name = '$username' AND Password = '$password' ");

//if the user exists
if (mysql_num_rows($rs)>0)
&#123;
  echo("The user already exists, please try again");
&#125;
else
&#123;
  //the user does not exist set him into the user table
  $sql = mysql_query("INSERT INTO myUsers VALUES ( '$username', '$password'  ) ");
	echo("You have registered");
&#125; ?>
That's my code!!! but i'm confused... ok i have the database, and the table... but the information that is entered does not save to the table.. am i missing something?

?>
Goowe
Forum Commoner
Posts: 94
Joined: Mon Mar 15, 2004 9:51 am
Location: Southeast Alaska

Post by Goowe »

Code: Select all

<?php
$query = "INSERT INTO myUsers (username, password) VALUES ('".$username."', '".$password."')";

mysql_query($query);
?>
The "myUsers (username, password) VALUES..." part is I think what you need. username is the title for the column where usernames are stored, password is the title for the column where passwords are stored.
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

he had the query right, he jsut wasn't actually querying it...
Goowe
Forum Commoner
Posts: 94
Joined: Mon Mar 15, 2004 9:51 am
Location: Southeast Alaska

Post by Goowe »

Oh... thanks for the cover ill :wink: I owe ya another one!
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

o wait, no i was wrong. He was querying it.... but the SQL was wrong!!

So Goowe you were right, i was wrong! hehe
Goowe
Forum Commoner
Posts: 94
Joined: Mon Mar 15, 2004 9:51 am
Location: Southeast Alaska

Post by Goowe »

*shines with pride* Thanks ill :wink: I believe my ego has been boosted five points
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

lol, don't it feel good?! hehe
Faith
Forum Newbie
Posts: 7
Joined: Sun Mar 14, 2004 10:30 pm

Thanks...

Post by Faith »

I'll have to give that a go :) thanks!!! :D
Post Reply