Jump to content

help trouble error code 500 internal server


ecabrera

Recommended Posts

hey i modifyed a script and it wont work this code is suppose to to register user and then there suppose to recieve a email and when they click on it it would say account is activate but instead it doesnt work when i click on it it just says http error code:500 internal server error i dont what is going wrong can someone please help me the email activation is suppose to look like www.mywebsite.com/activate?php/id=x&code=3456756

 

the x is the users id and the code is random numbers the will be generate 

 

 

below i will have this scripts plz help

 

<?php $title = "Register"; ?>
<?php require("styles/top.php"); ?>
<div id='full'>
<?php

$form = "<form action='register.php' method='post' enctype='multipart/form-data'>
<table cellspacing='10px'>
<tr>
	<td></td>
	<td><font color='red'>*</font> are required</td>
</tr>
<tr>
	<td>First Name:</td>
	<td><input type='text' name='firstname' class='textbox' size='35'><font color='red'>*</font></td>
</tr>
<tr>
	<td>Last Name:</td>
	<td><input type='text' name='lastname' class='textbox' size='35'><font color='red'>*</font></td>
</tr>
<tr>
	<td>Username:</td>
	<td><input type='text' name='username' class='textbox' size='35'><font color='red'>*</font></td>
</tr>
<tr>
	<td>Email:</td>
	<td><input type='text' name='email' class='textbox' size='35'><font color='red'>*</font></td>
</tr>
<tr>
	<td>Password:</td>
	<td><input type='password' name='password' class='textbox' size='35'><font color='red'>*</font></td>
</tr>
<tr>
	<td>Confirm Password:</td>
	<td><input type='password' name='repassword' class='textbox' size='35'><font color='red'>*</font></td>
</tr>
<tr>
	<td>Avatar:</td>
	<td><input type='file' name='avatar'></td>
</tr>
<tr>
	<td>Youtube Username:</td>
	<td><input type='text' name='youtube' class='textbox' size='35'></td>
</tr>
<tr>
	<td>Bio/About:</td>
	<td><textarea name='bio' cols='35' rows='5' class='textbox'></textarea></td>
</tr>
<tr>
	<td></td>
	<td><input type='submit' name='submitbtn' value='Register' class='button'></td>
</tr>
</table>
</form>";

if ($_POST['submitbtn']){

	$firstname = strip_tags($_POST['firstname']);
	$lastname = strip_tags($_POST['lastname']);
	$username = strip_tags($_POST['username']);
	$email = strip_tags($_POST['email']);
	$password = strip_tags($_POST['password']);
	$repassword = strip_tags($_POST['repassword']);
	$youtube = strip_tags($_POST['youtube']);
	$bio = strip_tags($_POST['bio']);

	$name = $_FILES['avatar']['name'];
	$type = $_FILES['avatar']['type'];
	$size = $_FILES['avatar']['size'];
	$tmpname = $_FILES['avatar']['tmp_name'];
	$ext = substr($name, strrpos($name, '.'));

	if ($firstname && $lastname && $username && $email && $password && $repassword){
		if ($password == $repassword){
			if (strstr($email, "@") && strstr($email, ".") && (strlen($email) >= 6)){

				require("scripts/connect.php");

				$query = mysql_query("SELECT * FROM users WHERE username='$username'");
				$numrows = mysql_num_rows($query);
				if ($numrows == 0){

					$query = mysql_query("SELECT * FROM users WHERE email='$email'");
					$numrows = mysql_num_rows($query);
					if ($numrows == 0){

						$pass = md5(md5($password));
						$date = date("F d, Y");

						if ($name){
							move_uploaded_file($tmpname, "avatars/$username.$ext");
							$avatar = $username.$ext;
						}
						else
							$avatar = "defavatar.png";

						//generate random code
						$code = rand(11111111, 99999999);

						//register into db
						$register = mysql_query("INSERT INTO users VALUES ('', '$firstname', '$lastname', '$username', '$email', '$pass', '$avatar', '$bio', '$youtube', '', '0', '$code', '0', '$date')");
						//send activation email
						$webmaster = "Admin@*****.com";
						$subject = "Activate Your Account";
						$headers = "From: ******<$webmaster>";
						$message = "Hello $firstname. Welcome to *******.com Below is a link for you to activate your account on ******.com\n\n 
<a href='http://www.*******.com/login.php'>Click Here to Activate Your Account: http://www.*******.com/activate.php?id=$idcode=$code</a>";


						mail($email, $subject, $message, $headers);

						echo "Thank You for registering. You must now activate your account throught the activation email that has been sent to <b>$email</b>. You must activate your account to be able to login. If you are haveing problems please contact the site administrator at <a href='mailto:admin@*******.com'>Admin@*******.com</a>.";

					}
					else
						echo "That email is already taken. $form";
				}
				else
					echo "That username is already taken. $form";
			}
			else
				echo "You did not enter a valid email. $form";
		}
		else
			echo "Your passwords did not match. $form";
	}
	else
		echo "You did not fill in all the required fields. $form";
}
else
	echo "$form";

?>
</div>
<?php require("styles/bottom.php"); ?>

 

activaton

 

<?php $title = "Activate Your Account"; ?>
<?php require("styles/top.php"); ?>
<div id='full'>
<?php

require('connect.php')

$id = $_GET['id'];
$code = $_GET['code'];

if ($id&&$code)
        {


		$check = mysql_query ("SELECT * FROM users WHHERE id='$id' AND code='$code'")
		$checknum = mysql_num_rows($check);

		if ($checknum==1)

		{

			//run a query to activate the account
			$acti = mysql_query ("UPDATE users SET activated='1' WHERE id='$id'");
		die("Your account is activated. You may now log in")	

		}

		else 
		    die("Invalide ID or Activation code.");

		         }
        else
	 die("Data Missing!");

?>

<?php require("styles/bottom.php"); ?>

Link to comment
Share on other sites

<?
$title = "Activate Your Account"; 
require("styles/top.php"); 
require('connect.php');			

$id = $_GET['id'];	
$code = $_GET['code'];		

if ($id&&$code)        
{									

 $check = mysql_query ("SELECT * FROM users WHHERE id='$id' AND code='$code'");		
 $checknum = mysql_num_rows($check);						
 if ($checknum==1)						
 {			 				
	//run a query to activate the account				
	$acti = mysql_query ("UPDATE users SET activated='1' WHERE id='$id'");
	die("Your account is activated. You may now log in");							
}							
else 			    
die("Invalide ID or Activation code.");						         
}       
else		 die("Data Missing!");
require("styles/bottom.php"); ?>

Link to comment
Share on other sites

I got it to go to that activation page but nothing appears only the header and when i get the activation email  and i click on www.mywebsite.com/activate.php?id=x&code=3456756

it does say anything  and it does not activate becuase i go to check it to phpmyadmin and it says 0 and it should be 1

Link to comment
Share on other sites

<?

$title = "Activate Your Account"; 

require("styles/top.php"); 

require('connect.php');  

 

$id = 1;

$code = 3456756;  

 

if ($id&&$code)       

{

 

$check = mysql_query ("SELECT * FROM users WHHERE id='$id' AND code='$code'");

$checknum = mysql_num_rows($check);

if ($checknum==1)

{

//run a query to activate the account

$acti = mysql_query ("UPDATE users SET activated='1' WHERE id='$id'");

die("Your account is activated. You may now log in");

}else    

die("Invalide ID or Activation code.");        

}     

else die("Data Missing!");

require("styles/bottom.php");

 

?>

run this code and see what happen to used id 1;

Link to comment
Share on other sites

nope still dont see anything and u added and extra h in where maybe it has something to do with the registration here take a look at it

 

<?php $title = "Register"; ?>
<?php require("styles/top.php"); ?>
<div id='full'>
<?php

$form = "<form action='register.php' method='post' enctype='multipart/form-data'>
<table cellspacing='10px'>
<tr>
	<td></td>
	<td><font color='red'>*</font> are required</td>
</tr>
<tr>
	<td>First Name:</td>
	<td><input type='text' name='firstname' class='textbox' size='35'><font color='red'>*</font></td>
</tr>
<tr>
	<td>Last Name:</td>
	<td><input type='text' name='lastname' class='textbox' size='35'><font color='red'>*</font></td>
</tr>
<tr>
	<td>Username:</td>
	<td><input type='text' name='username' class='textbox' size='35'><font color='red'>*</font></td>
</tr>
<tr>
	<td>Email:</td>
	<td><input type='text' name='email' class='textbox' size='35'><font color='red'>*</font></td>
</tr>
<tr>
	<td>Password:</td>
	<td><input type='password' name='password' class='textbox' size='35'><font color='red'>*</font></td>
</tr>
<tr>
	<td>Confirm Password:</td>
	<td><input type='password' name='repassword' class='textbox' size='35'><font color='red'>*</font></td>
</tr>
<tr>
	<td>Avatar:</td>
	<td><input type='file' name='avatar'></td>
</tr>
<tr>
	<td>Youtube Username:</td>
	<td><input type='text' name='youtube' class='textbox' size='35'></td>
</tr>
<tr>
	<td>Bio/About:</td>
	<td><textarea name='bio' cols='35' rows='5' class='textbox'></textarea></td>
</tr>
<tr>
	<td></td>
	<td><input type='submit' name='submitbtn' value='Register' class='button'></td>
</tr>
</table>
</form>";

if ($_POST['submitbtn']){

	$firstname = strip_tags($_POST['firstname']);
	$lastname = strip_tags($_POST['lastname']);
	$username = strip_tags($_POST['username']);
	$email = strip_tags($_POST['email']);
	$password = strip_tags($_POST['password']);
	$repassword = strip_tags($_POST['repassword']);
	$youtube = strip_tags($_POST['youtube']);
	$bio = strip_tags($_POST['bio']);

	$name = $_FILES['avatar']['name'];
	$type = $_FILES['avatar']['type'];
	$size = $_FILES['avatar']['size'];
	$tmpname = $_FILES['avatar']['tmp_name'];
	$ext = substr($name, strrpos($name, '.'));

	if ($firstname && $lastname && $username && $email && $password && $repassword){
		if ($password == $repassword){
			if (strstr($email, "@") && strstr($email, ".") && (strlen($email) >= 6)){

				require("scripts/connect.php");

				$query = mysql_query("SELECT * FROM users WHERE username='$username'");
				$numrows = mysql_num_rows($query);
				if ($numrows == 0){

					$query = mysql_query("SELECT * FROM users WHERE email='$email'");
					$numrows = mysql_num_rows($query);
					if ($numrows == 0){

						$pass = md5(md5($password));
						$date = date("F d, Y");

						if ($name){
							move_uploaded_file($tmpname, "avatars/$username.$ext");
							$avatar = $username.$ext;
						}
						else
							$avatar = "defavatar.png";

						//generate random code
						$code = rand(11111111, 99999999);

						//register into db
						$register = mysql_query("INSERT INTO users VALUES ('', '$firstname', '$lastname', '$username', '$email', '$pass', '$avatar', '$bio', '$youtube', '', '0', '$code', '0', '$date')");
						//send activation email
						$webmaster = "Admin@*******.com";
						$subject = "Activate Your Account";
						$headers = "From: *****<$webmaster>";
						$message = "Hello $firstname. Welcome to ******.com Below is a link for you to activate your account on *******.com\n\n 
<a href='http://www.******.com/login.php'>Click Here to Activate Your Account: http://www.******.com/activate.php?id=$id&code=$code</a>";


						mail($email, $subject, $message, $headers);

						echo "Thank You for registering. You must now activate your account throught the activation email that has been sent to <b>$email</b>. You must activate your account to be able to login. If you are haveing problems please contact the site administrator at <a href='mailto:admin@*******.com'>Admin@******.com</a>.";

					}
					else
						echo "That email is already taken. $form";
				}
				else
					echo "That username is already taken. $form";
			}
			else
				echo "You did not enter a valid email. $form";
		}
		else
			echo "Your passwords did not match. $form";
	}
	else
		echo "You did not fill in all the required fields. $form";
}
else
	echo "$form";

?>
</div>
<?php require("styles/bottom.php"); ?>

Link to comment
Share on other sites

i see only my background n header thats all no errors im sure theres no errors but theres sumthing in my script that doesnt let user activate there account this is wat happens i register for an account after that i get an email n click the link in the email n it takes me to the activation page which only the background n header appear n it doesnt say "your account has been activate click here to log in"

Link to comment
Share on other sites

Check the source. Maybe the messages are hidden in bad HTML?

 

Did you fix your typos? In the current version you've posted I've noticed a few like $check = mysql_query ("SELECT * FROM users WHHERE id='$id' AND code='$code'")

 

And you also realize that when you use die() no more PHP code will be executed? Including require("styles/bottom.php");

Link to comment
Share on other sites

<?
$title = "Activate Your Account";
require("styles/top.php"); 
require('connect.php'); 
          
$id = 1;   
$code = 3456756;       

if ($id&&$code)         
{                               

$check = mysql_query ("SELECT * FROM users WHERE id='$id' AND code='$code'");         
$checknum = mysql_num_rows($check);                     
if ($checknum==1)                     
{                            
//run a query to activate the account                  
$acti = mysql_query ("UPDATE users SET activated='1' WHERE id='$id'");      
die("Your account is activated. You may now log in");                        
}else                 
die("Invalide ID or Activation code.");                           
}       
else       die("Data Missing!");

require("styles/bottom.php");

?>

Link to comment
Share on other sites

this is the orginal script the orginal script is setup so when users activate there atcount they would need to verfy it and after that the would click on a link on the email we sent them after that they would have to put the a random codenwhich would look like http://wwwmywebsite.com/activate?code=545877979

but i dont want that i just want users to go to there email and click on the link to verfiy and done there account is verfiy

 

for registration and activation

 

registration

 

<?php $title = "Register"; ?>
<?php require("styles/top.php"); ?>
<div id='full'>
<?php

$form = "<form action='register.php' method='post' enctype='multipart/form-data'>
<table cellspacing='10px'>
<tr>
	<td></td>
	<td><font color='red'>*</font> are required</td>
</tr>
<tr>
	<td>First Name:</td>
	<td><input type='text' name='firstname' class='textbox' size='35'><font color='red'>*</font></td>
</tr>
<tr>
	<td>Last Name:</td>
	<td><input type='text' name='lastname' class='textbox' size='35'><font color='red'>*</font></td>
</tr>
<tr>
	<td>Username:</td>
	<td><input type='text' name='username' class='textbox' size='35'><font color='red'>*</font></td>
</tr>
<tr>
	<td>Email:</td>
	<td><input type='text' name='email' class='textbox' size='35'><font color='red'>*</font></td>
</tr>
<tr>
	<td>Password:</td>
	<td><input type='password' name='password' class='textbox' size='35'><font color='red'>*</font></td>
</tr>
<tr>
	<td>Confirm Password:</td>
	<td><input type='password' name='repassword' class='textbox' size='35'><font color='red'>*</font></td>
</tr>
<tr>
	<td>Avatar:</td>
	<td><input type='file' name='avatar'></td>
</tr>
<tr>
	<td>Youtube Username:</td>
	<td><input type='text' name='youtube' class='textbox' size='35'></td>
</tr>
<tr>
	<td>Bio/About:</td>
	<td><textarea name='bio' cols='35' rows='5' class='textbox'></textarea></td>
</tr>
<tr>
	<td></td>
	<td><input type='submit' name='submitbtn' value='Register' class='button'></td>
</tr>
</table>
</form>";

if ($_POST['submitbtn']){

	$firstname = fixtext($_POST['firstname']);
	$lastname = fixtext($_POST['lastname']);
	$username = fixtext($_POST['username']);
	$email = fixtext($_POST['email']);
	$password = fixtext($_POST['password']);
	$repassword = fixtext($_POST['repassword']);
	$website = fixtext($_POST['website']);
	$youtube = fixtext($_POST['youtube']);
	$bio = fixtext($_POST['bio']);

	$name = $_FILES['avatar']['name'];
	$type = $_FILES['avatar']['type'];
	$size = $_FILES['avatar']['size'];
	$tmpname = $_FILES['avatar']['tmp_name'];
	$ext = substr($name, strrpos($name, '.'));

	if ($firstname && $lastname && $username && $email && $password && $repassword){
		if ($password == $repassword){
			if (strstr($email, "@") && strstr($email, ".") && (strlen($email) >= 6)){

				require("scripts/connect.php");

				$query = mysql_query("SELECT * FROM users WHERE username='$username'");
				$numrows = mysql_num_rows($query);
				if ($numrows == 0){

					$query = mysql_query("SELECT * FROM users WHERE email='$email'");
					$numrows = mysql_num_rows($query);
					if ($numrows == 0){

						$pass = md5(md5($password));
						$date = date("F d, Y");

						if ($name){
							move_uploaded_file($tmpname, "avatars/$username.$ext");
							$avatar = $username.$ext;
						}
						else
							$avatar = "defavatar.png";

						$code = substr(md5(rand(1111111111, 99999999999999)), 2, 25);

						mysql_query("INSERT INTO users VALUES ('', '$firstname', '$lastname', '$username', '$email', '$pass', '$avatar', '$bio', '$website', '$youtube', '', '0', '$code', '0', '$date')");

						$webmaster = "Admin@******.com";
						$subject = "Activate Your Account";
						$headers = "From:******<$webmaster>";
						$message = "Hello $firstname. Welcome to ******.com Below is a link for you to activate your account on******.com\n\n Clicke Here to Activate Your Account: http://www.******.com/activate.php?code=$code";

						mail($email, $subject, $message, $headers);

						echo "Thank You for registering. You must now activate your account through the activation email that has been sent to <b>$email</b>. You must activate your account to be able to login. If you are having problems please contact the site administrator at <a href='mailto:admin@******.com'>Admin@*******.com</a>.";

					}
					else
						echo "That email is already taken. $form";
				}
				else
					echo "That username is already taken. $form";
			}
			else
				echo "You did not enter a valid email. $form";
		}
		else
			echo "Your passwords did not match. $form";
	}
	else
		echo "You did not fill in all the required fields. $form";
}
else
	echo "$form";

?>
</div>
<?php require("styles/bottom.php"); ?>

 

activateion

 

<?php $title = "Activate Your Account"; ?>
<?php require("styles/top.php"); ?>
<div id='full'>
<?php

$getcode = $_GET['code'];

$form = "<form action='activate.php' method='post'>
<table>
<tr>
	<td>Username:</td>
	<td><input type='text' name='username' size='35'></td>
</tr>
<tr>
	<td>Password:</td>
	<td><input type='password' name='password' size='35'></td>
</tr>
<tr>
	<td></td>
	<td><input type='submit' name='submitbtn' vlaue='Activate'></td>
</tr>
</table>
</form>";

if ($_POST['submitbtn']){
	$code = strip_tags($_POST['code']);
	$username = strip_tags($_POST['username']);
	$password = strip_tags($_POST['password']);

	if ($code && $username && $password){
		if (strlen($code) == 25){
			$pass = md5(md5($password));
			require("scripts/connect.php");
			$query = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$pass'");
			$numrows = mysql_num_rows($query);
			if ($numrows == 1){

				$row = mysql_fetch_assoc($query);
				$dbcode = $row['code'];

				if ($code == $dbcode){

					mysql_query("UPDATE users SET active='1' WHERE username='$username'");

					echo "You account has been activated. You may now login. <a href='login.php'>Click here to login.</a>";

				}
				else
					echo "You activation code incorrect. $form";
			}
			else
				echo "Your username and password are invalid. $form";
		}
		else
			echo "You have not supplied a valid code. $form";
	}
	else
		echo "You did not fill in the entire form. $form";
}
else
	echo "$form";
?>

</div>
<?php require("styles/bottom.php"); ?>

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.