I am not trying to do anything too fancy, I am just trying to get some $_SESSION data to save and use it on the next page, but so far no luck.
Its saving some data to $_SESSION['name'] and then loading the header, but that header re-directs using another header command (no whitespace obviously) and then on that page, it has a php include that i need to call the superglobal $_SESSION['name']. At the moment i just want to print the thing, i will deal with functionality once i can actually pass the session data to the next page.
Input page has:
Code:
$sql = "SELECT UID FROM User
WHERE Username='$_POST[username]'
AND Password='$_POST[password]'
AND CID='$_POST[CompanyID]';";
$result = mysql_query($sql);
$num = mysql_numrows($result);
if ($num == 1) {
$sql = "SELECT CompanyName FROM Company WHERE CID ='$_POST[CompanyID]';";
$result2 = mysql_query($sql);
$companyname = mysql_result($result2, 0);
$id = mysql_fetch_assoc($result);
setcookie("nameofcookie", $value, time()+3500);
//setcookie("auth", "yes", time()+300);
//setcookie("id", $id['id']);
//setcookie("username", $id['username']);
$successful = "Location: ./".$companyname."/index.php";
session_start();
$_SESSION['name'] = $_POST['CompanyID'].$_POST['username']; //companyID.username is the format for session name.
session_write_close();
mysql_close();
header ($successful); //where to go if successful
} else {
header ('Location: login.php'); // where to if fail
}
?>
And I am trying to call $_SESSION['name'] on the other page, but the piece of code is inside a small <div> include, loaded by the header page.
header page calls this:
index.php (which re-directs to)
<?php
header( 'Location: ./menu/' ) ;
?>
Code: <HTML> BLAH BLAH BLAH
</head>
<body>
<?php include '../includes/pageheader.php'; ?>
<more html>
Here is the contents of that include (pageheader.php).
Code: <div id="headerbar">
<a href="index.php"><img alt="Solace Logo" src="../images/solacelogo.jpg" class="solacelogo" /></a>
<ul id="toppageoption">
<li><a href="../help.php">Help</a></li>
<li><a href="../changecompany.php">Change Company</a></li>
<li><a href="../logout.php">Logout (<?php echo $_SESSION['name']; ?>)</a></li>
</ul>
</div>
Posting to another Site?
I have software that people install.When they install it, is there a way to make it post their domain name to my website?I know I could do a header('location: http//www.mysite.com/id=?domain.com');
PHP time (deadline within one week)
I have a column ['projdue'], which stores the deadline for a project.I have PHP code and <span class>'s to show projects that are within timescale, due today and overdue:Code:
Problem with php's rename function
So, i'm having a problem with the php rename function. Basically my script 'delete_user.php' attempts to copy the users xml file(i stored all users information, in xml files as a backup of my
Error when call dll from oracle
Hi all, please help me!
How to grab certain words ??
I am working with this APIReturns JSON.curl http://letsbetrends.com/api/current_trendsHow to grab just the trending topics Which come after "name" : "xxxxxxxx" (the x's)Or how to
Session
I am having a little trouble with a session. Not sure if it is my browser or what. I know I do not have any trouble logging into forums such at these, so not sure why this is not working.first the
ctype() validation - allowing illegal characters
Hello,I use ctype() to filter and validate a user form. However, I am trying to allow certain characters.Example:Code: //Validate Copay $allow = array('$', '.'); if (!empty($copay)
Adding post count
How would I make it so everytime someone clicks submit on my form, their row in the database for their post count goes up 1.
MASS PM
Hello all, I'm trying to send mass private messages to users in my database but keep getting an error... and was hoping someone could help me out.You have an error in your SQL syntax; check the manual
sql problems
I am having a small problem with my sql statement. it is inserting into 4 of the fields. fields it is inserting into:FirstLastemailpasswordit is saying the record has been added. is there something