forumnz Posted January 1, 2007 Share Posted January 1, 2007 Im trying to make a script that will post to a database...I had it working and then I added age, phone, and area, its not working now.[code]<html><head><style type="text/css"><!--body { font-family: Tahoma, Arial, sans-serif; font-size: 12px; font-weight: bold;}--></style><title>Account Creation System</title></head><body><?php/// install file checkif (!file_exists("install.txt")){ die("Admin - Please run install first");};/// import configrequire("config.php");/// connect to database$con=mysql_connect($mysql_hst,$mysql_us,$mysql_ps);if (!$con) { die('Could not connect: ' . mysql_error() . '<br /><br />Check your config file or contact your server support team.'); }; /// select DBif (!mysql_select_db($mysql_db, $con)){die ("Could not connect to the database you specified. Make sure it exists and is correctly named within config.php");};/// active or create?if ($_GET["activec"] == "true"){$setact = "UPDATE members SET active = '1' WHERE username = '" . str_replace(' ','/space/',mysql_real_escape_string($_GET["usrc"])) . "'";mysql_query($setact, $con);die ('Account active<br /><br /><a href="index.html">Login Now!</a>');};///Thing goes here/// check filledif ($_POST["username"] == "") { die ("You did not enter a username"); };if ($_POST["password"] == "") { die ("You did not enter a password"); };if ($_POST["password"] != $_POST["password_confirm"]) { die ("Your passwords don't match"); };if ($conf == "yes"){if ($_POST["email"] == "") {die ("Site Admin is requested that you supply a valid email address. Please go back and try again");};if ($_POST["age"] == "") { die ("You did not enter an age"); };if ($_POST["phone"] == "") { die ("You did not enter a phone number"); };if ($_POST["area"] == "") { die ("You did not enter an area"); };};//lowercase$usernamel = strtolower($_POST[username]);$usernamel = str_replace(' ','/space/',$usernamel);/// check whether usrname exists$extresult = mysql_query("SELECT * FROM members");while($row = mysql_fetch_array($extresult)) { if ($row[username] == $usernamel){die ('The username is already inuse. Please go back and try again<br /><br /><a href="create.html">Try Again</a>');}; }; /// encode psswrd$passenc = $_POST[password];$passencon = base64_encode($passenc);/// insert data under conditionsif ($conf == "yes"){$active = "0";} else { $active = "1"; };$store = "INSERT INTO `members` (`id`, `username`, `password`, `active`, `age`, `phone`, `area`) VALUES ('', '" . mysql_real_escape_string($usernamel) . "', '" . $passencon . "', '" . $active . "')";mysql_query($store, $con);/// confirmation$to = $_POST[email];$subject = "Members Account";$headers = "MIME-Version: 1.0\r\n";$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";$headers .= "From: " . $sendmail;$body = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML><HEAD><META http-equiv=Content-Type content="text/html; charset=iso-8859-1"><META content="MSHTML 6.00.2900.2912" name=GENERATOR><STYLE></STYLE></HEAD><BODY bgColor=#ffffff><DIV><FONT face=Tahoma>Thank you for signing up to the members area at ' . $_SERVER['HTTP_HOST'] . ' <BR><BR>Click to activate your account: </FONT><A href="http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?usrc=' . $_POST[username] . '&activec=true"><FONT face=Tahoma>http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '</FONT></A> </DIV></BODY></HTML>'; if ($conf == "yes") { mail($to, $subject, $body, $headers); echo ("Thank you " . str_replace('/space/',' ',$usernamel) . " your account has been created. Please activate it using the email that has been sent to your address"); } else { echo ('Your account has been created and is also active. You may login now.<br /><br /><a href="index.html">Login Now!</a>');};?></body></html>[/code]Please and Thanks. Link to comment https://forums.phpfreaks.com/topic/32488-mysql-thingy/ Share on other sites More sharing options...
AndyB Posted January 1, 2007 Share Posted January 1, 2007 Please define what you mean by "not working". Link to comment https://forums.phpfreaks.com/topic/32488-mysql-thingy/#findComment-150950 Share on other sites More sharing options...
forumnz Posted January 1, 2007 Author Share Posted January 1, 2007 I enter all information, then it says acount active ( like it should ) but when i try to login it wont work.I also went and had a look at the database using phpmyadmin and it wasnt there, the rest before i made this modification were though. Link to comment https://forums.phpfreaks.com/topic/32488-mysql-thingy/#findComment-150952 Share on other sites More sharing options...
forumnz Posted January 1, 2007 Author Share Posted January 1, 2007 bump... Link to comment https://forums.phpfreaks.com/topic/32488-mysql-thingy/#findComment-150954 Share on other sites More sharing options...
corbin Posted January 1, 2007 Share Posted January 1, 2007 Change all your mysql_queries to have or die(mysql_error()) on the end and tell us of any errors that are created. Link to comment https://forums.phpfreaks.com/topic/32488-mysql-thingy/#findComment-150957 Share on other sites More sharing options...
forumnz Posted January 1, 2007 Author Share Posted January 1, 2007 can you give me an example... i think im doing it wrong Link to comment https://forums.phpfreaks.com/topic/32488-mysql-thingy/#findComment-150961 Share on other sites More sharing options...
corbin Posted January 1, 2007 Share Posted January 1, 2007 mysql_query($setact, $con) or die (mysql_error()); Link to comment https://forums.phpfreaks.com/topic/32488-mysql-thingy/#findComment-150965 Share on other sites More sharing options...
forumnz Posted January 1, 2007 Author Share Posted January 1, 2007 It says...Parse error: syntax error, unexpected $end in /usr/local/psa/home/vhosts/freshlook.co.nz/httpdocs/thing/create.php on line 98 Link to comment https://forums.phpfreaks.com/topic/32488-mysql-thingy/#findComment-150975 Share on other sites More sharing options...
forumnz Posted January 1, 2007 Author Share Posted January 1, 2007 anyone? Link to comment https://forums.phpfreaks.com/topic/32488-mysql-thingy/#findComment-151019 Share on other sites More sharing options...
corbin Posted January 1, 2007 Share Posted January 1, 2007 [code] } else { echo ('Your account has been created and is also active. You may login now.<br /><br /><a href="index.html">Login Now!</a>');};[/code]Doesnt need the ; on the end. Link to comment https://forums.phpfreaks.com/topic/32488-mysql-thingy/#findComment-151025 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.