hi
in my assignment, i am trying to navigate from one page to another using php. the this when a user register ah would like to navigate to a welcome page letting the user know that they are now a register member but the problem i am having is that one minute it would navigate to the login page instead and another time it would break down but in the browser u are seeing like it trying to navigate to the welcome.php but it break down. dont if it is something int the welcome.php page is what causing it or the codes that i am using is the problem. cant tell which is which even though I have used the header function and it still will not work
can someone tell me what is wrong, maybe an extra pair of eyes would be much appreciated. here is the codes for the both pages.
What I have tried:
here is the first codes
<?php
header('Location: welcome.php');
?>
<?php
$register=$_POST['register_user'];
if(isset($register))
{
$title=$_POST['title'];
$fullname=$_POST['fullname'];
$lastname=$_POST['lastname'];
$screenname=$_POST['screenname'];
$email=$_POST['email'];
$gender=$_POST['gender'];
$address=$_POST['address'];
$mypwd=$_POST['mypwd'];
$db_host="localhost";
$db_user="root";
$db_pass="";
$conn=mysqli_connect($db_host,$db_user,$db_pass) or die (mysqli_connect_error());
mysqli_select_db($conn, 'national_wonders') or die (mysqli_error($conn));
$sql="SELECT * FROM members WHERE screenname='$screenname'";
$result= mysqli_query($conn, $sql) or die ("ERROR:" .mysqli_error());
$rowcount=mysqli_num_rows($result);
if($rowcount >= 1)
{
"<script type=\"text/javascript\">
alert('Screenname already exits!!');
window.location=/login.html\";
</script>";
}
else
{
$sql = "INSERT INTO members
VALUES('$title', '$fullname', '$lastname', '$screenname', '$email', '$gender', '$address', MD5('$mypwd'))";
if(mysqli_query($conn,$sql))
{
session_start();
$_SESSION['user']=$screenname;
mysqli_close($conn);
}
else
{
echo "Error inserting values into database";
}
}
}
?>
here is the codes for the welcome page
<?php
session_start();
if(!isset($_SESSION['view']))
{
header("location:../php/popupbox.php");
}
?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title> Welcome </title>
<link rel="stylesheet" type="text/css" href="css/stylesheet.css" />
</head>
<body>
<div id="container">
<div id="header">
<div id="banner">
<img src="images/header.jpg" alt="header" />
</div>
</div>
<div id="navbar">
<ul>
<li><a href="../index.html" id="tlinks" class="toplinks">Homepage</a></li>
<li><a href="featureNaturalWonders.html" id="thold" class="toplinks">Feature Natural Wonders</a></li>
<li><a href="contact.html" id="linkhold" class="toplinks" >Contact Us</a></li>
<li><a href="register.html" id="phold" class="toplinks"> Sign Up</a></li>
<li><a href="login.html" id="loglinks"class="toplinks"> Login</a></li>
<li><a href="aboutus.html" id="panlinks" class="toplinks"> About Us</a></li>
</ul>
<form method="post" id="search" action="" >
<input type="text" name="search" value=""/>
<input type="submit" value="Search"/>
</form>
</div>
<div id="contentArea">
<h1>CONGRATULATIONS!!!!</h1>
<p>
You are now a registered member!!
</p>
<p>
Please enter your screenname and password to see the information you have submitted.
</p>
<form method="post" action="../PHP/data.php">
*Screenname: <input type="text" name="screenname" /> <br/><br/>
*Password: <input type="password" name="mypwd" /> <br/><br/>
<input type="submit" value="VIEW" />
</form>
<div id="footerbox">
<div id="footerholder">
<div id="">
<a href="../index.php">Homepage</a>
<a href="popupbox.php">Popup box </a>
<a href="featureNationalWonders.php">Feature National Wonders</a>
</div>
</div>
</div>
</div>
</body>
</html>