lssjg Posted April 18, 2006 Share Posted April 18, 2006 Hey, i really need this kinda urgent.I wrote the whole thing apart from a small part in the php page which is just the creating a password.... that is the phpfreaks password something..... i got it off some part of the siteSHORT SUMMARY OF IT:I have made it to take a username and an email address. Once done, you get taken to register.phpregister.html[code]<form method="post" action="../../../../../site1/users/register.php"> <table width="100%" border="0" cellpadding="4" cellspacing="0"> <tr> <td width="22%" align="left" valign="top">Username:</td> <td width="78%"><input name="username" type="text" /></td> </tr> <tr> <td width="22%" align="left" valign="top">Email Address:</td> <td width="78%"><input name="email" type="text"></td> </tr> <tr> <td width="22%" align="left" valign="top"> </td> <td width="78%"><input type="submit" value="Register"></td> </tr> </table></form>[/code]ok please note that in the next thing i call back registerform.html .... it is the exact same thing as register.html (which is above).. - the reason why i have two pages is because i have text on one saying other stuff....ANYWAY...register.php[code]<?include 'db.php';$username = $_POST['username'];$email = $_POST['email'];$username = stripslashes($username);$email = stripslashes($email);if((!$username) || (!$email)){ echo 'You didnt fill in the following fields<br />'; if(!$username){ echo "- Username<br />"; } if(!$email){ echo "- Email<br />"; } echo "<br><br>"; include 'register.html'; exit(); } $sql_username_check = mysql_query("SELECT username FROM users WHERE username='$username'"); $username_check = mysql_num_rows($sql_username_check); if($username_check > 0){ echo "Please fix the following error: <br />"; if($username_check > 0){ echo "The username you have selected has already been used by another member of this site. Please choose a different Username!<br />"; unset($username); } include 'registerform.html'; exit(); } function makeRandomPassword() { $salt = "abchefghjkmnpqrstuvwxyz0123456789"; srand((double)microtime()*1000000); $i = 0; while ($i <= 7) { $num = rand() % 33; $tmp = substr($salt, $num, 1); $pass = $pass . $tmp; $i++; } return $pass;}$random_password = makeRandomPassword();$db_password = md5($random_password);$info2 = htmlspecialchars($info);$sql = mysql_query("INSERT INTO users (username, email, password, signup_date) VALUES('$username', '$email', '$db_password', now())") or die (mysql_error());if(!$sql){ echo 'There has been an error creating your account. Please contact the through the <a href="../../../../../../forum/">forum</a> or through the contact form.';} else { $userid = mysql_insert_id(); $subject = "Blah Site - Membership Info"; $message = "Dear $username, Thanks for registering...blahblahblah To activate your membership, please click here: http://www.this will be filled in when uploaded onto a site (yet to come).com/activate.php?id=$userid&code=$db_password Once you activate your memebership, you will be able to login with the following information: Username: $username Password: $random_password Then you can change your pasword in your user panel once you are logged in. Thanks! The bull sh-t admin Team http://www.blahdjskfajdsbhfksjad.com This is an automated response, please do not reply! or you will die!..... i can ryme hehe"; $from = 'edited@out.com'; mail($email, $subject, $message, $from); echo 'Your membership information has been mailed to your email address! Please check it and follow the directions!';}?>[/code]That is all....NOW firstly i am doing this on my laptop so i am working off apache, php5 and mysql with phpmyadmin.My error isColumn count doesn't match value count at row 1It is black text on a white page..... no red boxes or anything....i thought it might be a mysql error... so here is my table[code]CREATE TABLE users ( userid int(25) NOT NULL auto_increment, username varchar(25) NOT NULL default '', email_address varchar(25) NOT NULL default '', password varchar(25) NOT NULL default '', user_level enum('0','1','2','3','4','5','6','7','8','9','10') NOT NULL default '0', signup_date datetime NOT NULL default '0000-00-00 00:00:00', last_login datetime NOT NULL default '0000-00-00 00:00:00', activated enum('0','1') NOT NULL default '0', ban enum('0','1') NOT NULL default '0', gender enum('0','1','2') NOT NULL default '0', PRIMARY KEY (userid)) TYPE=MyISAM COMMENT='Membership Information';[/code]It's something along those lines.... i don't know how to get the sql out of phpmyadmin - i put it in... but i forgot to save a copy in notpad..... - bad me!anyway...can someone help! Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted April 18, 2006 Share Posted April 18, 2006 The only thing I can see wrong in there is here...$sql = mysql_query("INSERT INTO users (username, email, password, signup_date) VALUES('$username', '$email', '$db_password', now())") or die (mysql_error());you have now())''try '" . now() ."' and see what happens. Quote Link to comment Share on other sites More sharing options...
redbullmarky Posted April 18, 2006 Share Posted April 18, 2006 [!--quoteo(post=365946:date=Apr 18 2006, 12:20 PM:name=ToonMariner)--][div class=\'quotetop\']QUOTE(ToonMariner @ Apr 18 2006, 12:20 PM) [snapback]365946[/snapback][/div][div class=\'quotemain\'][!--quotec--]The only thing I can see wrong in there is here...$sql = mysql_query("INSERT INTO users (username, email, password, signup_date) VALUES('$username', '$email', '$db_password', now())") or die (mysql_error());you have now())''try '" . now() ."' and see what happens.[/quote]NOW() is a mysql function not php, so as far as i can see, this line SHOULD work. 4 fields and 4 values... Quote Link to comment Share on other sites More sharing options...
lssjg Posted April 19, 2006 Author Share Posted April 19, 2006 thanks.... i fixed it....i swaped email and password and it works!thanks!Now 2nd question...it gives me a mail function error.. it needs to be adjusted in php.ini with the details of a smtp server.Only problem. I don't know where to find it.I have a hotmail and a gmail account.Is there anyway i can find the smtp address of gmail or hotmail - preferably hotmail.I have googled it and got no where!i have triedmx1.hotmail.commx.hotmail.commx2.hotmail.commx3.hotmail.commx4.hotmail.commail.hotmail.comsmtp.hotmail.comanyway to find out!? Quote Link to comment Share on other sites More sharing options...
wisewood Posted April 19, 2006 Share Posted April 19, 2006 gmail should have smtp details somewhere in the settings for the account (if you have one) as they allow you to set up your gmail account in your favourite mail software. Quote Link to comment Share on other sites More sharing options...
lssjg Posted April 20, 2006 Author Share Posted April 20, 2006 yeah i found it...it aparently isINGOING: pop.gmail.comOUTGOING smtp.gmail.comso i am trying the 2nd currently... and i restarted apache and ....ERROR:Warning: mail() [function.mail]: SMTP server response: 530 5.7.0 Must issue a STARTTLS command first j7sm324703nzd in E:\Websites\Server\www\site1\users\register.php on line 91Your membership information has been mailed to your email address! Please check it and follow the directions!ok... i tried to register with the script i posted above.... and i got this... the is i don't know what!And the your membership thing is simly what i got it to each when it is sent. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.