Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 04-18-2007, 12:22 PM Session Passing
Red_X_'s Avatar
Extreme Talker

Posts: 158
Location: Houston
Trades: 0
I want my variables to pass to my validate.php page. However if I use the "header" attribute I am unable. Apparently from my reading SESSION cannot be passed using header.

Now why not use require? My site is designed around one simple template, that using a switch statement to go through out the page and click on links, only reloading the text, and fields. All images and or graphics of any nature stay were they are using less bandwith and time.

How can I get SESSION variables to pass, the following is my code.
register.php
PHP Code:
$c =mysql_connect("$host""$user""$pass") or die(mysql_error());
$d mysql_select_db("$data"$c) or die(mysql_error());
function 
protect($value){
$value mysql_real_escape_string($value);
$value stripslashes($value);
$value strip_tags($value);
}
$action $_GET['act'];
protect($action);
 
if(!
$action){
echo 
"
 <table border=0 cellspacing=3 cellpadding=3>\n
    <form name=register method=post action=\"register.php?act=register\">\n
    <tr><td>Desired Username<font color='FF0000'>*</font></td><td><input type=text name=username maxlength=32>\n</td></tr>\n
    <tr><td>Password<font color='FF0000'>*</font></td><td><input type=password name=password maxlength=64>\n</td></tr>\n
    <tr><td>Password Confirm<font color='FF0000'>*</font></td><td><input type=password name=passconf maxlength=64>\n</td></tr>\n
    <tr><td>E-Mail<font color='FF0000'>*</font></td><td><input type=text name=email>\n</td></tr>\n
    <tr><td>E-Mail Confirm<font color='FF0000'>*</font></td><td><input type=text name=econf>\n</td></tr>\n
    <tr><td>Age(day, month, year)<font color='FF0000'>*</font></td>\n
   <td><select name=day>\n"
;
        for(
$i=1;$i<99;$i++){
        echo 
"<option value=\"$i\">$i</option>\n";
        }
echo 
"</select>\n
  <select name=month>\n"
;
        for(
$i=1;$i<13;$i++){
        echo 
"<option value=\"$i\">$i</option>\n";
        }
echo 
"</select>\n
    <select name=year>\n"
;
        for(
$i=2007;$i>1900;$i--){
        echo 
"<option value=\"$i\">$i</option>\n";
        }
echo 
"</select></td></tr>\n
    <tr><td>Your Name<font color='FF0000'>*</font></td><td><input type=text name=name maxlength=32>\n
 <tr><td>Address<font color='FF0000'>*</font></td><td><input type=text name=address maxlength=50>\n
 <tr><td>Phone<font color='FF0000'>*</font></td><td>(<input type=text name=areacode maxlength=3 size=3>)
       <input type=text name=digits maxlength=3 size=3>
       <input type=text name=lastdigits maxlength=4 size=4>
 <tr><td>Plan: <font color='FF0000'>*</font></td><td><select name=plan>
        <option name=->--Select Plan--</option>
        <option name=basic>Basic: $3.45</option>
        <option name=professional>Professional: $5.45</option>
        <option name=Ultimate>Ultimate: $15.00</option>
    <tr><td></td><td><center><input type=submit value=\"Sign Up\">\n</center></table>"
;
}
if(
$action == "register"){
$username $_POST['username'];
$password $_POST['password'];
$passconf $_POST['passconf'];
$email $_POST['email'];
$econf $_POST['econf'];
$day $_POST['day'];
$month $_POST['month'];
$year $_POST['year'];
$name $_POST['name'];
$address $_POST['address'];
$phone $_POST['areacode'] . $_POST['digits'] . $_POST['lastdigits'];
$plan $_POST['plan']; 
protect($username);
protect($password);
protect($passconf);
protect($email);
protect($econf);
protect($day);
protect($month);
protect($year);
protect($name);
protect($address);
protect($phone);
protect($plan);
        if(isset(
$username) && isset($password) && isset($passconf) && isset($email) && isset($econf) && isset($day) && isset($month) && isset($year) && isset($name) && isset($address) && isset($phone) && isset($plan)){
      if (
$plan == "-") {
  echo 
"Please Select a Plan"
   } else {
            if(
strlen($username) < || strlen($username) > 32){
            echo 
"username is either too short or too long\n";
            }else {
                if(
strlen($password) < || strlen($password) > 64){
                echo 
"password is either too short or too long\n";
                }else {
                    if(
strlen($email) < || strlen($email) > 125){
                    echo 
"email is either too short or too long\n";
                    }else {
                        if(
strlen($name) < || strlen($name) > 64){
                        echo 
"your name is either too short or too long\n";
                        }else {
                            if(!
is_numeric($day) || !is_numeric($month) || !is_numeric($year)){
                            echo 
"you entered an invalid birthday\n";
                            }else {
                                if(
$day || $day 31){
                                echo 
"your birthday (day) is invalid\n";
                                }else {
                                    if(
$month || $month 12){
                                    echo 
"your birthday (month) is invalid\n";
                                    }else {
                                        if(
$year 1906 || $year 1989){
                                        echo 
"your birthday (year) is invalid\n You must be 18 to register.";
                                        }else {
                                            
$array = array('.');
                                            
$math $year/4;
                                            if((
in_array($math,$array)) && $day "28" && $month == "2"){
                                            echo 
"your birthday does not exist\n";
                                            }else {
                                                if(
$password != $passconf){
                                                echo 
"your passwords do not match\n";
                                                }else {
                                                    if(
$email != $econf){
                                                    echo 
"your emails do not match\n";
                                                    }else {
                                                        
$checkemail "/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i";
                                                        if(!
preg_match($checkemail,$email)){
                                                        echo 
"the email you entered is incorrect";
                                                        }else {
                                                            
$sql "SELECT * FROM `users` WHERE `username` ='$username'";
                                                            
$res mysql_query($sql) or die(mysql_error());
                                                            if(
mysql_num_rows($res) > 0){
                                                            echo 
"this username already exists";
                                                            }else {
                                                                
$sql "SELECT * FROM `users` WHERE `email` ='$email'";
                                                                
$res mysql_query($sql) or die(mysql_error());
                                                                if(
mysql_num_rows($res) > 0){
                                                                echo 
"the email you supplied is already in use";
                                                                } else {
                                                                    
$sql "SELECT * FROM `users` WHERE `ip` ='$_SERVER[REMOTE_ADDR]'";
                                                                    
$res mysql_query($sql) or die(mysql_error());
                                                                    if(
mysql_num_rows($res) > 0){
                                                                    echo 
"your ip is already in use";
                                                                    } else {
                                                                        
$password md5($password);
                                                                        
$bday "$month/$day/$year";
                                                                        
$date date("F j, Y @ g:i:s a");
                                                                        
$ip $_SERVER['REMOTE_ADDR'];
 
                                                                       
header("Location: index.php?page=Validate"
                                                                        }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
       }
    }    

Validate.php
PHP Code:
<?php
echo "<br />Is this information correct?<form method=post action=complete.php><br />";
 
$_SESSION['username'] = $username
//$_SESSION['password'] = $password;
$_SESSION['email'] = $email
$_SESSION['day'] = $day;
$_SESSION['month'] = $month
$_SESSION['year'] = $year;
$_SESSION['name'] = $name;
$_SESSION['address'] = $address;
$_SESSION['phone'] = $phone;
$_SESSION['plan'] = $plan
$_SESSION['ip'] = $ip;
$_SESSION['bday'] = $bday;
$_SESSION['date'] = $date;
echo 
"<strong>Username</strong>: $username<br />
   <strong>Password</strong>: What You Set it To.<br />
   <strong>Email</strong>: 
$email<br />
  <strong> Date of Birth</strong>: 
$day$month$year<br />
   <strong>Name</strong>: 
$name<br />
   <strong>Address</strong>: 
$address<br />
   <strong>Phone</strong>: 
$phone<br />
   <strong>Order</strong>: 
$plan<br /><br /><br />";
 
 
   print 
"<input type=Submit value=Confirm>
   </form><br />
   If Not <a href='javascript:history.back()'>Back</a>"
;
 
?>
complete.php
PHP Code:
<?php
 
 
$c 
=mysql_connect("$host""$user""$pass") or die(mysql_error());
$d mysql_select_db("$data"$c) or die(mysql_error());
 
$username $_SESSION['username'];
 
$password $_SESSION['password'];
 
$passconf $_SESSION['passconf'];
 
$email $_SESSION['email'];
 
$econf $_SESSION['econf'];
 
$day $_SESSION['day'];
 
$month $_SESSION['month'];
 
$year $_SESSION['year'];
 
$name $_SESSION['name'];
 
$address $_SESSION['address'];
 
$phone $_SESSION['phone'];
 
$plan $_SESSION['plan']; 
 
$date $_SESSION['date'];
 
$bday $_SESSION['bday'];
 
$ip $_SESSION['ip'];
 
$sql "INSERT INTO `users` (`username` , `password` , `email` , `ip` , `name` , `bday` , `date`, `address`, `phone`, `plan` )VALUES ('$username', '$password', '$email', '$ip', '$name', '$bday', '$date', '$address', '$phone', '$plan');";
                                                                        
$res mysql_query($sql) or die(mysql_error());
                                                                        echo 
"thank you for registering, you may now <a href='index.php?page=login'>Login</a>\n"
 
?>
Note: all of this works if I change in "register.php" to use
PHP Code:
require_once('validate.php'); 
I just want to avoid using that. And cookies.

Thanks for any help!
__________________
"Good News Everyone, by reading this your hearing my voice."
Red_X_ is offline
Reply With Quote
View Public Profile Visit Red_X_'s homepage!
 
 
Register now for full access!
Old 04-18-2007, 09:19 PM Re: Session Passing
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
In order to use sessions, you require to use session_start() at the top of your script before any output is sent to the browser. Session vars will then carry over from page to page for you then (as long as you start the sessions on every page though).
__________________

<mgraphic /> - I don't have a solution but I admire the problem.

Last edited by mgraphic; 04-18-2007 at 09:20 PM.. Reason: added a remmark
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 04-18-2007, 09:35 PM Re: Session Passing
Red_X_'s Avatar
Extreme Talker

Posts: 158
Location: Houston
Trades: 0
Quote:
Originally Posted by mgraphic View Post
In order to use sessions, you require to use session_start() at the top of your script before any output is sent to the browser. Session vars will then carry over from page to page for you then (as long as you start the sessions on every page though).
Oh my bad, thats in my header.php so its started and closed through out the page.

And i've only recently added that(this morning) used to have it set on those pages, but I figured why not have it run through out the site. And it works fine if I use it like that.(when using require)
__________________
"Good News Everyone, by reading this your hearing my voice."
Red_X_ is offline
Reply With Quote
View Public Profile Visit Red_X_'s homepage!
 
Old 04-20-2007, 02:14 AM Re: Session Passing
Red_X_'s Avatar
Extreme Talker

Posts: 158
Location: Houston
Trades: 0
-bump-

Just really need help getting this, i've been racking my brain.
__________________
"Good News Everyone, by reading this your hearing my voice."
Red_X_ is offline
Reply With Quote
View Public Profile Visit Red_X_'s homepage!
 
Old 04-20-2007, 01:37 PM Re: Session Passing
shivaji's Avatar
Ultra Talker

Posts: 321
Trades: 0
My English is very bad, sorry. If you don't like to require validate.php then you need session_start() in validate.php, too.

Shivaji
__________________

Please login or register to view this content. Registration is FREE
- uncommon free scripts

Please login or register to view this content. Registration is FREE
- Städte, Sport, Party, Gourment, Apartments, Hotels
shivaji is offline
Reply With Quote
View Public Profile Visit shivaji's homepage!
 
Old 04-20-2007, 03:20 PM Re: Session Passing
Red_X_'s Avatar
Extreme Talker

Posts: 158
Location: Houston
Trades: 0
Quote:
Originally Posted by shivaji View Post
My English is very bad, sorry. If you don't like to require validate.php then you need session_start() in validate.php, too.

Shivaji
The header attribute doesn't pass the $_SESSION variable, so i'm tring to figure out how to get them to save. So the session_start(). Besides as I stated above that my session_start(); is called in my header.php
__________________
"Good News Everyone, by reading this your hearing my voice."
Red_X_ is offline
Reply With Quote
View Public Profile Visit Red_X_'s homepage!
 
Reply     « Reply to Session Passing
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.24669 seconds with 12 queries