Jump to content

[SOLVED] registration script


cfgcjm

Recommended Posts

I'm trying to write a simple registration script but i can't get it to write to my database...any ideas?

 

<?php
require ('mysql.php');
if (isset ($_POST['submit'])) { 
$username = $_POST['username'];
$psend=$_POST['password'];
$password = md5 ($_POST['password']);
$first_name=$_POST['first_name'];
$last_name=$_POST['last_name'];
$email=$_POST['email'];
$interest=$_POST['interest'];
$food=$_POST['food'];
$sport=$_POST['sport'];

$add_sql = "INSERT INTO users (users_id, username, password, first_name, last_name, email, interest, fav_food, sport) VALUES (0, '$username', '$password', '$first_name', '$last_name', '$email', '$interest', '$food', '$sport')";
}
?>

Link to comment
Share on other sites

<?php
$add_sql = "INSERT INTO users (users_id, username, password, first_name, last_name, email, interest, fav_food, sport) VALUES (0, '$username', '$password', '$first_name', '$last_name', '$email', '$interest', '$food', '$sport')";
?>

 

Should be:

<?php
mysql_query("INSERT INTO users (users_id, username, password, first_name, last_name, email, interest, fav_food, sport) VALUES (0, '$username', '$password', '$first_name', '$last_name', '$email', '$interest', '$food', '$sport')");
?>

 

Also, you should definately look into SQL-Injection as you are wide open to it...

Link to comment
Share on other sites

cfgcjm,

Double check everything, ensure you are properly able to even establish a connection to the database in the mysql.php file which is included at the top.

 

Also, be sure your query is valid, make sure the column names and everything also line up.

Link to comment
Share on other sites

mysql_query("INSERT INTO users (users_id, username, password, first_name, last_name, email, interest, fav_food, sport) VALUES (0, '$username', '$password', '$first_name', '$last_name', '$email', '$interest', '$food', '$sport')") or die(mysql_error());

try to see the error( add error reporting )

Link to comment
Share on other sites

it showed just a blank window...no error, in both FF and IE however when i submit the form which is register.php it changes the address to accept.php (which is correct) but it is appended as this:

 

http://digiconmediagroup.com/Homeplate/portal/accept.php?username=brinser&password1=1234&password2=1234&fname=chris&interest=food&lname=Miller&food=hotdog&email=millercj@etown.edu&sport=football&submit=submit

 

...the form data

Link to comment
Share on other sites

You're using if (isset ($_POST['submit'])) {  and a bunch of $_POST variables... The url you gave us indicates you're using method="get" on the html form itself...

 

Change the method to "post" and it should work.

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.