Jump to content

Recommended Posts

<?php session_start();

include 'Utilitys/Connection.php';
include 'Utilitys/Functions.php';

RedLogin();


$role = "1";	
$id = mt_rand(0, 9999999999); 
$time = date("F j, Y, g:i a");
$signup = date("F j, Y, g:i a");	
$username = protect($_POST['username']);	
$password = protect($_POST['password']);
$firstname = protect($_POST['FirstName']);	
$lastname = protect($_POST['LastName']);	
$email = protect(validateEmail($_POST['Email']));
$ip = $_SERVER['REMOTE_ADDR'];
$gender = protect($_POST['gender']);
$dobday = protect($_POST['dobday']);
$dobmonth = protect($_POST['dobmonth']);
$dobyear = protect($_POST['dobyear']);

if (isset($_POST['submit'])) {

if (isset($username) && isset($password) && isset($firstname) && isset($lastname) && isset($email) && isset($gender) && isset($dobday) && isset($dobmonth) && isset($dobyear)) {


$flag = "INSERT INTO `users` (`id`, `username`, `password`, `firstname`, `lastname`, `email`, `role`, `time`, `signup`, `gender`, `ip`, `dobmonth`, `dobday`, `dobyear`)                      
VALUES('$id', '$username', md5('$password'), '$firstname', '$lastname', '$email', '$role', '$time', '$signup', '$gender', '$ip', '$dobmonth', '$dobday', '$dobyear')" or die (mysql_error());	

$run = mysql_query($flag);

header('Location: Login.php?i=1');


} else {

print "<p align='center'>Please Fill All Required Fields.</p>";

}
}

?>

 

 

the insert is not working is just doing the refferal, does anyone know why ?,

 

Thanks.

 

James.

Link to comment
https://forums.phpfreaks.com/topic/159688-solved-mysql-insert-not-working/
Share on other sites

$flag = "INSERT INTO `users` (`id`, `username`, `password`, `firstname`, `lastname`, `email`, `role`, `time`, `signup`, `gender`, `ip`, `dobmonth`, `dobday`, `dobyear`)                     

VALUES('$id', '$username', md5('$password'), '$firstname', '$lastname', '$email', '$role', '$time', '$signup', '$gender', '$ip', '$dobmonth', '$dobday', '$dobyear')" or die (mysql_error());  ??? your setting a string not querying yet

 

 

$flag = "INSERT INTO `users` (`id`, `username`, `password`, `firstname`, `lastname`, `email`, `role`, `time`, `signup`, `gender`, `ip`, `dobmonth`, `dobday`, `dobyear`)                     

VALUES('$id', '$username', md5('$password'), '$firstname', '$lastname', '$email', '$role', '$time', '$signup', '$gender', '$ip', '$dobmonth', '$dobday', '$dobyear')" or die (mysql_error());  ??? your setting a string not querying yet

 

 

am i :S, it used to work and then i changed it a bit and it dont and thats just a error trigger its working on all of my other script perfectly dont understand why this isnt working :S

am i :S, it used to work and then i changed it a bit and it dont and thats just a error trigger its working on all of my other script perfectly dont understand why this isnt working :S

 

If there is an error in your SQL then that or die is not going to notice it.

 

All the best

 

Keith

 

PS - Random ID will cause problems if Id is the primary key and by chance you land up with a duplicate. Might be a million to one chance, but million to one chances seem to occur 9 times out of 10.

am i :S, it used to work and then i changed it a bit and it dont and thats just a error trigger its working on all of my other script perfectly dont understand why this isnt working :S

 

If there is an error in your SQL then that or die is not going to notice it.

 

All the best

 

Keith

 

PS - Random ID will cause problems if Id is the primary key and by chance you land up with a duplicate. Might be a million to one chance, but million to one chances seem to occur 9 times out of 10.

 

oh :S what trigger can i use that will work ?,

 

and agreed i will be making a ID checker soon where it will check if the random generated id exists already and if it does it will re-generate :)

Hi

 

<?php session_start();

include 'Utilitys/Connection.php';
include 'Utilitys/Functions.php';

RedLogin();


$role = "1";	
$id = mt_rand(0, 9999999999); 
$time = date("F j, Y, g:i a");
$signup = date("F j, Y, g:i a");	
$username = protect($_POST['username']);	
$password = protect($_POST['password']);
$firstname = protect($_POST['FirstName']);	
$lastname = protect($_POST['LastName']);	
$email = protect(validateEmail($_POST['Email']));
$ip = $_SERVER['REMOTE_ADDR'];
$gender = protect($_POST['gender']);
$dobday = protect($_POST['dobday']);
$dobmonth = protect($_POST['dobmonth']);
$dobyear = protect($_POST['dobyear']);

if (isset($_POST['submit'])) {

if (isset($username) && isset($password) && isset($firstname) && isset($lastname) && isset($email) && isset($gender) && isset($dobday) && isset($dobmonth) && isset($dobyear)) {


$flag = "INSERT INTO `users` (`id`, `username`, `password`, `firstname`, `lastname`, `email`, `role`, `time`, `signup`, `gender`, `ip`, `dobmonth`, `dobday`, `dobyear`)                      
VALUES('$id', '$username', md5('$password'), '$firstname', '$lastname', '$email', '$role', '$time', '$signup', '$gender', '$ip', '$dobmonth', '$dobday', '$dobyear')";	

$run = mysql_query($flag) or die(mysql_error());

header('Location: Login.php?i=1');


} else {

print "<p align='center'>Please Fill All Required Fields.</p>";

}
}

?>

 

Strictly speaking if you want to check the ID then you should do it locking the table, or just catch a duplicate key error and retry.

 

All the best

 

Keith

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.