Jump to content

very simple singup script


Recommended Posts

Hi guys another signup script, I've been reading here for a few hours now and still can't solve my problem so I decided to post here.

 

Anyways the problem is the data isn't getting to the mysql here's my code by the way the signup is more of a add user script and is only available once someone has signed in:

 

http://privatepaste.com/d915cqIufh

Link to comment
Share on other sites

You did not specify the action page on the form.

 

<form method="post" name="frmadd" id="frmadd">

 

Change to : <form method="post" name="frmadd" id="frmadd" action="NameOFactionPAge.php">

 

The user name and password to connect to your mysql database is available on the page. It may be  misused. So please delete the page as soon as possible.

 

 

Link to comment
Share on other sites

 

Please use the following lines of code:

 

<?php

 

    if ($_POST['user'] != NULL && $_POST['pass'] != NULL )

    {

 

/*  Please add the two lines of code to connect to your MySql

  and select MySql Database */

 

$user = $_POST['user'];

$pass = $_POST['pass'];

 

 

$query=mysql_query("INSERT INTO users_logins (user_id, user_password) VALUES ('$user', PASSWORD('$pass'))")

or die('Error' . mysql_error());

 

 

mysql_close($con);

}

?>

 

<h1>Login successful</h1>

 

<form method="post" name="frmadd" id="frmadd" action="action.php">

<input name="user" type="text" id="user">

<input name="pass" type="password" id="pass">

<input type="submit" name="btnadd" value="Add">

</form>

Link to comment
Share on other sites

Did you add the lines for connecting to MySql and select Database. Are you sure that database and table with the same name exists ?

 

Also please check after submit the form, it goes to the same page.

 

One change needed:

 

1. Change the action page with name of your action page

 

The you assign the sql query to a variable and prints it:

    $sql ="INSERT INTO users_logins (user_id, user_password) VALUES ('$user', PASSWORD('$pass'))";   

    echo $sql; exit();

    $query=mysql_query($sql);

Link to comment
Share on other sites

 

Add this lines to check whether your program makes  successful connection with database

 

$con = mysql_connect('mysql2.freehostia.com','greval5_greval5','somepassword') or die("Couldnot connect to MySql");

mysql_select_db("greval5_greval5",$con) or die("Couldnot select Database");

 

 

Link to comment
Share on other sites

I made the action the same script (main.php)

 

and also changed the query with the most current line you gave me and it did not return the error and the echo was:

 

INSERT INTO users_logins (user_id, user_password) VALUES ('john', PASSWORD('smith'))

 

also the tables do exist because I'm able to login using the users i created through phpmyadmin sql interface... very odd...

Link to comment
Share on other sites

 

I think some connection problem still existing. 

 

Could you replace the sql query with this ?

 

$sql = 'SELECT * FROM users_logins";

$re = mysql_query($sql);

echo "Th e number of Records ".mysql_num_rows($re);

 

If the connection is established, then it will output the number of records in user_logins table.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.