For some reason when I login with this code nothing displays. Please Help.
FILE func/functions.php
[php]<?php
function connect(){
mysql_connect(“localhost”,“alumni”,“Panda467”);
mysql_select_db(“simley_alumni”);
}
function secure($var){
$var = HTML_ENTITIES($var);
$var = $var;
}
function register_chk(){
if(isset(
$_POST[‘register’])){
//
//
$fname = $_POST[‘fname’];
$lname = $_POST[‘lname’];
$posit = $_POST[‘posit’];
$occu = $_POST[‘occu’];
$email = $_POST[‘email’];
$jnumber = $_POST[‘jnumber’];
$yrspld = $_POST[‘yrspld’];
$favmem = $_POST[‘favmem’];
$errors = array();
//Start Checks
// make sure fields aren't empty
if(
empty($fname) ||
empty($lname) ||
empty($posit) ||
empty($occu) ||
empty($email) ||
empty($jnumber) ||
empty($yrspld) ||
empty($favmem)
) {
//
$errors[] = ‘All fields are required!!’;
//
}
//all fields have data entered in them
//if statements to check things
if(strlen($fname) > 20){
$errors[] = 'Name has to be less than 20 letters!';
}
if(preg_match("/[\d]/", $fname)){
$errors[] = 'First Name may not contain a number';
}
if(strlen($lname)>30){
$errors[] = 'Last Name has to be less than 30 letters!';
}
if(preg_match("/[\d]/", $lname)){
$errors[] = 'Last Name may not contain a number';
}
//end of name check
//postion is a dropdown / doesn't need to be checked
// end of position
if(!is_numeric($jnumber)){
$errors[] = 'Jersey # must be a number';
} else {
if($jnumber <= 0){
$errors[] = 'Jersey # must be a positive number';
} else {
if(strlen($jnumber)>3){
$errors[] = 'Jersey # must be less than a 3 digit #';
} else {
if(!preg_match("/./",$jnumber)){
$errors[] = 'Jersey # must be a non-decimal #';
}
}
}
if(!is_numeric($yrspld)){
$errors[] = 'Years Played # must be a number';
} else {
if($jnumber <= 0){
$errors[] = 'Years Played # must be a positive number';
} else {
if(strlen($jnumber)>2){
$errors[] = 'Years Played # must be less than a 2 digits';
} else {
if(!preg_match("/./",$jnumber)){
$errors[] = 'Years Played must be a non-decimal #';
}
}
}
//email check
if(filter_var($email,FILTER_VALIDATE_EMAIL) === FALSE ) {
$errors[] = 'Please Enter a Valid Email Address';
}
//end of email check
//
}
}
if(!empty($errors)){
foreach($errors as $error){
echo '<h5 style="color:red">*'.$error.'</h5>';
}
}else{
//submit form
mysql_query("INSERT INTO `simley_alumni`.`ALUMNI`
(`email`, `password`, `username`, `graduation_year`, `industry_survey`, `job_networking`, `speaker`, `id`)
VALUES
('$email', '".md5($pass)."', '$fname', '1234', 'N', 'N', 'N', NULL)");
/*
mysql_query("INSERT INTO `list`
(
`first_name`,
`last_name`,
`email`,
`grad_year`,
`position`,
`occupation`,
`jersey_number`,
`years_played`,
`fave_memory`,
`checked`
)
VALUES
(
'$fname',
'$lname',
'$email',
$gradyear,
'$posit',
'$occu',
$jnumber,
$yrspld,
NULL,
'notchecked')");
*/
}
}
}
function form_display(){
if(!isset($_SESSION['id'])){
?>
<form action="index.php" method="POST">
rr
<h1>Login Here</h1>
<p>Email: <input type="text" name="email" /></p>
<p>Password: <input type="password" name="pass" /></p>
<p><input type="submit" name="login" /></p>
<br />
<p>If you don't have an account<br />Register <a href="register.php"> Here </a></p>
</form>
<?php
}
}
?>
<?php
function logged_in_dis(){
if(isset($_SESSION['id'])){
//info to be displayed if user is logged in
echo '
Your Logged In As '.$_SESSION['email'] . ' with an id of ' . $_SESSION['id'] .'
LOGOUT
Edit Info Edit Info
' ; } } function login(){ if(isset($_POST['login'])){ $errors = array(); $email = $_POST['email']; $pass = $_POST['pass']; if(empty($email) || empty($pass)){ $errors[] = 'You must fill in all of the fields'; }else{ $checkinfo = mysql_query("SELECT * FROM `ALUMNI` WHERE `email` = '$email' AND `password` = '$pass' "); $num_chkinfo = mysql_num_rows($checkinfo) or die(mysql_error()); if($num_chkinfo == 0){ $errors[] = 'No users Found'; } } if(!empty($errors)){ foreach($errors as $error){ echo '
*'.$error.'
'; } }else{ //Create SESSIONS echo'FORM IS VALID
'; while($row = mysql_fetch_assoc($checkinfo)){ $_SESSION['id'] = $row['id']; $_SESSION['email'] = $row['email']; //header("LOCATION: index.php"); } } } } function reg_form_display(){ if(!isset($_SESSION['id'])){ ?> <form action="register.php" method="POST" style="height:auto;" />
<h1>Register Here</h1>
<div id="errors">
<?php
register_chk();
?>
</div>
<form action="index.php" method="POST" id="alumniform">
<p>First Name:<input type="text" name="fname" value="" /></p>
<p>Last Name:<input type="text" name="lname" value="" /></p>
<p>Position:<select name="posit" value="posit" />
<option>Offense</option><option>Quarterback</option><option>
Half back
Full Back
Left tackle Left guard
Center
Right guard
Right tackle
Wide receiver 1 Wide Reciever 2Tight End
Occupation:
Email:
Jersey #
# Of Years Played:
Favorite Memory
<p>
<input type="submit" id="submit" name="register"
value="Create Account">
</p>
<br /><br /><br />
</form>
<?php
}else{
echo 'YOUR CURRENTLY LOGGED IN
Your Logged In As '.$_SESSION['email'] . ' with an id of ' . $_SESSION['id'] .'
LOGOUT' ; } } function userinfo_display(){ $getinfo = mysql_query("SELECT * FROM `ALUMNI` WHERE `id` =".$_SESSION['id']." "); $row = mysql_fetch_assoc($getinfo); ?>
<form action="#" method="POST">
<?php
//email password username graduation_year industry_survey job_networking speaker id
echo '<h2>Edit your info here</h2>
<p>ID: <input type="text" value="'.$_SESSION['id'].'" name="" /></p>
<p>graduation_year: <input type="text" value="'.$row['graduation_year'].'" name="" /></p>
<p>Industry Survey: <input type="text" value="'.$row['industry_survey'].'" name="" /></p>
'
;
?>
</form>
<?php
}
?>[/php]
FILE - index.php
[php]<?php
session_start();
include’func/functions.php’;
connect();
?>
<div id="content">
<br><br><br><center>
<?php
login();
form_display();
logged_in_dis();
?>
fgasdljhsdfjkfhsdnajk
</center>
</div>
</div>
[/php]