Click here to Skip to main content
15,891,629 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi there

it is me again, i have this registration page when a user login it should redirect you to a welcome page, I am having a similar problem at to one user who was experiencing the same problem.

at one time it was going to the welcome page, but there were errors in the firstname an lasname variable. how to echo it out. apparently i had code it wrong, so it was picking up the error, try fixing and I have no idea I did or didn't know now when i tried registering, it is blank

i have a login page also and that and all is not working. here is the 2 sets of codes. one is the register.php and the other is the welcome page codes.

this is what i have so far. i know that I have asked this question before abot the name

What I have tried:

PHP
<pre><?php

	session_start();
	
	if(isset($_SESSION['user']))
	{
		header('Location:login.php');
	}

?>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11.dtd">

<html xmlns="http:www.w3.org/1999/xhtml"xml:lang="en" lang="en">

	<head>
		<title> Welcome - <?php echo "".$_SESSION['user']; ?></title>
	</head>
	<body>
		
		
			
			
			Welcome!!! <?php echo $_POST['firstname']; ?><!<br/><?php echo $_POST['lastname'];?>
			<?php
				echo " you are now a member of the Caribbean Culinary Network (CCIN). 
						Your monthly newsletter will be email to you."
			?>
	
	
	</body>
</html>


this is the register.php code
PHP
<pre><?php

		if(isset($_POST['submit']))
		{
			//capture the variable from the form and store in php variables
			
			$title=$_POST['title'];
			$firstname=$_POST['firstname'];
			$lastname=$_POST['lastname'];
			$address=$_POST['address'];
			$txtemail=$_POST['txtemail'];
			$gender=$_POST['gender'];
			$userName=$_POST['userName'];
			$pword=$_POST['pword'];
			
			//connecting to the server
			
			$db_host="localhost";
			$db_username="root";
			$db_password="";
			$con = mysqli_connect($db_host,$db_username,$db_password) or die (mysqli_connect_error());
			
			//select the database you want to query
			
			mysqli_select_db($con, 'food') or die (mysqli_error($con));
			$sql = "SELECT * FROM member WHERE userName = '$userName'";
			$result = mysqli_query($con, $sql) or die ("Error:".mysqli_error($con));
			$rowcount=mysqli_num_rows($result);
			
			if($rowcount >= 1)
			{
				echo "<script type=\"text/javascript\";
				alert('username already exist');
				window.location=\"register.html\";
				</script>";
			}//.....
			else
			{
				//insert data into table
				
				$sql = "INSERT INTO member VALUES('$title', '$firstname', '$lastname', 
						'$address', '$txtemail', '$gender', '$userName', MD5('$pword'))";
				
				if(mysqli_query($con, $sql))
					{
						mysqli_close($con);
						header("location:welcome.php");
					}
					else
					{
						echo "Error inserting into database".mysqli_error($con);
					}
			
				
				
			}//.......
			
			
			
		}
?>
Posted
Comments
MadMyche 4-May-18 12:49pm    
What is different between the users who this works for and those who don't? Browsers, browser extensions, and cookies all may have a role here: Session by default uses cookies and if they aren't enabled, the session may have issues

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900