gkjr1 Posted March 25, 2012 Share Posted March 25, 2012 I have no idea why it's doing it. I know I'm missing something, but everything looks right to me. When you submit the registration form it just does the error, and properties say its the process page, so this code below. Sorry posting it all, I'm just not sure period. <?php require('connect.php'); //check all the posted info function getInfo() { $error = array(); $fname = validateFirstname($_POST['fname']); $lname = validateLastname($_POST['lname']); $uname = validateUsername($_POST['uname']); $email = validateEmail($_POST['email']); $password = validatePass($_POST['password1'], $_POST['password2']); $phone = validatePhone($_POST['phone']); //check for errors error(); } function validateFirstname($str) { //This allows just alpha characters and must be at least 2 characters. if (preg_match('/^[a-zA-Z0-9]{2,}$/',$str)) { return preg_match('/^[a-zA-Z0-9]{2,}$/',$str); } else { $error[] = 'Please enter a valid first name!'; } } function validateLastname($str) { //This allows just alpha characters and must be at least 2 characters. if (preg_match('/^[a-zA-Z0-9]{2,}$/',$str)) { return mysql_real_escape_string($str); } else { $error[] = 'Please enter a valid last name!'; } } function validateUsername($str) { //connect to database $link = mysql_connect($db_host, $db_user, $db_pass); if (!$link) { die('Could not connect: ' . mysql_error()); } mysql_select_db($db_name); //pull usernames to make sure new is unique $sql = "SELECT username FROM users WHERE username = '".$str."'"; if ($sql == "") { //This allows just alphanumeric characters and must be 4 - 15 characters. if (preg_match('/^[a-zA-Z0-9]{4,15}$/',$str)) { return mysql_real_escape_string($str); } else { $error[] = 'Please enter a valid user name!'; } } else { $error[] = 'This user name is already registered!'; } } function validateEmail($str) { //connect to database $link = mysql_connect($db_host, $db_user, $db_pass); if (!$link) { die('Could not connect: ' . mysql_error()); } mysql_select_db($db_name); //pull usernames to make sure new is unique $sql = "SELECT email FROM users WHERE email = '".$str."'"; if ($sql == "") { if (preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/",$str)) { return mysql_real_escape_string($str); }else{ $error[] = 'Please enter a valid email!'; } } else { $error[] = 'This email is already registered!'; } } function validatePass($str, $str2) { //This allows just alphanumeric characters and must be 6-15 characters. if ($str == $str2) { if (preg_match('/^[a-zA-Z0-9]{6,15}$/',$str)) { return md5(mysql_real_escape_string($str)); } else { $error[] = 'Please enter a valid password!'; } } else { $error[] = 'Passwords do not match!'; } } function validatePhone($str) { //This allows just alpha characters and must be at least 2 characters. if (preg_match('/^[0-9]{0,11}$/',$str)) { return mysql_real_escape_string($str); } else { $error[] = 'Please enter a valid phone number!'; } } function error() { if ($error[] == '') { addInfo(); } else { echo "<a href='javascript: history.go(-1)'><-- Go Back</a><br>"; echo $error[]; } } function addInfo() { //setcookie("site_user", $Name, time() + 31536000, "/"); //setcookie("site_pass", $Password, time() + 31536000, "/"); //Connect to database from here $link = mysql_connect($db_host, $db_user, $db_pass); if (!$link) { die('Could not connect: ' . mysql_error()); } //activation link $a = md5(uniqid(rand(), true)); //select the database | Change the name of database from here mysql_select_db($db_name); $sql="INSERT INTO users (firstname,lastname,email,username,password,phone,active,ip,rank,acctcreated) VALUES ('$fname','$lname','$uname',$email','$lastpass','$phone',$a','$ip','$rank',NOW())"; } // Send the email: $message = " To activate your account, please click on this link:\n\n"; $message .= WEBSITE_URL . '/activate.php?email=' . urlencode($Email) . "&key=$activation"; mail($Email, 'Registration Confirmation', $message, 'From:'.EMAIL); // Flush the buffered output. // Finish the page: echo '<div class="success">Thank you for registering! A confirmation email has been sent to ' . $Email .' Please click on the Activation Link to Activate your account </div>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/259688-http-500-internal-server-error/ Share on other sites More sharing options...
The Little Guy Posted March 25, 2012 Share Posted March 25, 2012 look at your error logs. Quote Link to comment https://forums.phpfreaks.com/topic/259688-http-500-internal-server-error/#findComment-1330960 Share on other sites More sharing options...
gkjr1 Posted March 25, 2012 Author Share Posted March 25, 2012 I'm just getting back into coding after over a year of not doing it. Don't even remember where to check. Quote Link to comment https://forums.phpfreaks.com/topic/259688-http-500-internal-server-error/#findComment-1330961 Share on other sites More sharing options...
The Little Guy Posted March 25, 2012 Share Posted March 25, 2012 usually it is in a "Logs" directory where php is installed. One thing I see is your trying to make a class but have an invalid structure. class MyClass{ public $error = array(); public function validateFirstname($str){ if (preg_match('/^[a-zA-Z0-9]{2,}$/',$str)) { return preg_match('/^[a-zA-Z0-9]{2,}$/',$str); } else { $this->error[] = 'Please enter a valid first name!'; } } } Quote Link to comment https://forums.phpfreaks.com/topic/259688-http-500-internal-server-error/#findComment-1330962 Share on other sites More sharing options...
gkjr1 Posted March 25, 2012 Author Share Posted March 25, 2012 I was actually using just functions. I also cannot find my php.ini file on my host anywhere. May not have access, can't I just upload my own php.ini in my root? Quote Link to comment https://forums.phpfreaks.com/topic/259688-http-500-internal-server-error/#findComment-1330965 Share on other sites More sharing options...
gkjr1 Posted March 25, 2012 Author Share Posted March 25, 2012 <?php if (isset($_POST['submitted'])) { //This allows just alpha characters and must be at least 2 characters. if (preg_match('/^[a-zA-Z0-9]{2,}$/',$_POST['fname'])) { $fname = mysql_real_escape_string($_POST['fname']); } else { $error[] = 'Please enter a valid first name!'; } //This allows just alpha characters and must be at least 2 characters. if (preg_match('/^[a-zA-Z0-9]{2,}$/',$_POST['lname'])) { $lname = mysql_real_escape_string($_POST['lname']); } else { $error[] = 'Please enter a valid last name!'; } //This allows just alphanumeric characters and must be 4 - 15 characters. if (preg_match('/^[a-zA-Z0-9]{4,15}$/',$_POST['uname'])) { $uname = $_POST['uname']; } else { $error[] = 'Please enter a valid user name!'; } //check email if (preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/",$_POST['email'])) { $email = mysql_real_escape_string($_POST['email']); }else{ $error[] = 'Please enter a valid email!'; } //This allows just alphanumeric characters and must be 6-15 characters. if ($_POST['password1'] == $_POST['password2']) { if (preg_match('/^[a-zA-Z0-9]{6,15}$/',$_POST['password1'])) { $lastpass = md5($_POST['password1']); } else { $error[] = 'Please enter a valid password!'; } } else { $error[] = 'Passwords do not match!'; } //This allows just alpha characters and must be at least 2 characters. if (preg_match('/^[0-9]{0,11}$/',$_POST['phone'])) { $phone = mysql_real_escape_string($_POST['phone']); } else { $error[] = 'Please enter a valid phone number!'; } echo $lname .",". $fname .",". $uname .",". $email .",". $lastpass .",". $phone; } Even then throws the code. Please help someone its been hours of me trying to find the problem... Quote Link to comment https://forums.phpfreaks.com/topic/259688-http-500-internal-server-error/#findComment-1330996 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.