Jump to content

Search the Community

Showing results for tags 'session'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. my variables from page 1 are not being sent to page 2 using sessions. i have tried to echo them and it is not working. when i use print_r for the sessions on page2.php, all i see is "array()" on my site. can someone please help. page1.php <?php session_start(); { $_SESSION['questionsession'] = $question; $_SESSION['asession'] = $a; $_SESSION['bsession'] = $b; $_SESSION['csession'] = $c; $_SESSION['dsession'] = $d; $_SESSION['esession'] = $e; $_SESSION['answersession'] = $answer; $_SESSION['correctsession'] = $correct; } ?> page2.php <?php session_start(); $question = $_SESSION['questionsession']; $a = $_SESSION['asession']; $b = $_SESSION['bsession']; $c = $_SESSION['csession']; $d = $_SESSION['dsession']; $e = $_SESSION['esession']; $answer = $_SESSION['answersession']; $correct = $_SESSION['correctsession']; echo $question; // NOT WORKING!! ?>
  2. I have a mySQL database that is queried and displayed in tables in index.php. I have javascript and a file called up.php that handles a click on an <a> with the class "vote" in each table that is output from the query in index.php. I need to have a variable that willl define each MyValue from a field in each seperate row that is queried, so that when the a is clicked it passes the MyValue to the php file to be manipulated. Right now the MyValue is just being over written and is equal to the value of the last row queried..... and the database is updated frequently so I can't just set one to each row, it has to be dynamic im confused on what to do... please help! thanks in advance to anybody who can help me out!
  3. the first chunk of code is in my index.php file. I am trying to pass the $_SESSION['mes_id1'] variable into another php file called up.php and it will not get passed. the second chunk of code is the up.php file and the third chunk of code is my config.php file. any help is very much appreciated!!!!! thank you in advance!!!! index.php <?php session_id(); session_start(); mysql_connect("localhost", "FoleyHurley", "*******"); mysql_select_db("voting2"); ?> <div id="mipods" class="section2" style="display: none;"> <!-- assign mysql data rows to corresponding php variables --> <?php $sql = mysql_query("SELECT * FROM blogData ORDER BY id DESC"); $sql2=mysql_query("SELECT * FROM messages WHERE mod(mes_id,2) = 0 ORDER BY mes_id DESC"); $sql3=mysql_query("SELECT * FROM messages WHERE mod(mes_id,2) = 1 ORDER BY mes_id DESC"); while(($row = mysql_fetch_array($sql))&&($row2 = mysql_fetch_array($sql2))&&($row3 = mysql_fetch_array($sql3)) ){ $id = $row['id']; $title = $row['title']; $content = $row['content']; $category = $row['category']; $podcast = $row['podcast']; $datetime = $row['datetime']; $message1=$row2['msg']; $mes_id1=$row2['mes_id']; $totalvotes1=$row2['totalvotes']; $message2=$row3['msg']; $mes_id2=$row3['mes_id']; $totalvotes2=$row3['totalvotes']; $_SESSION['message1'] = $message1; $_SESSION['message2'] = $message2; $_SESSION['mes_id1'] = $mes_id1; $_SESSION['mes_id2'] = $mes_id2; $_SESSION['totalvotes1'] = $totalvotes1; $_SESSION['totalvotes2'] = $totalvotes2; ?> <?php // variable used to display file name of $podcast without the extension $noext = $podcast; $echodub = rawurlencode($podcast); // code to display $noext without the file extension $info = pathinfo($noext); $noext_name = basename($noext,'.'.$info['extension']); ?> <!-- echo php variables in html format, in a table with the class of "podcast" --> <table class="podcast" border="1"> <tr> <td class="title"> <?php echo $title; ?> </td> <td class="timeandcategory"> <?php echo $datetime; ?> <br> <?php echo $category; ?> <?php echo $_SESSION['mes_id1']; ?> <?php echo $_SESSION['mes_id2']; ?> <?php echo session_id(); ?> </td> </tr> <tr> <td class="content"> <?php echo $content; ?> </td> <td class="myfblike"> <a href="https://twitter.com/share" class="twitter-share-button" data-url="http://localhost:8888/blog1/index.php#<?php echo $noext; ?>" data-counturl="http://localhost:8888/blog1/index.php#<?php echo $noext; ?>" data-text="listen to SD's new podcast! www.sportdebaters.com#<?php echo $noext; ?> @SDebaters " data-related="SDebaters" data-hashtags="SDebaters">Tweet</a> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script> <span class='st_fblike_large' displayText='Facebook Like'></span><br> <span class='st_facebook_large' displayText='Facebook'></span><br> <span class='st_twitterfollow_large' displayText='Twitter Follow'></span><br> <span class='st_pinterest_large' displayText='Pinterest'></span><br> <span class='st_email_large' displayText='Email'></span><br> <span class='st_sharethis_large' displayText='ShareThis'></span><br> </td> </tr> <tr> <td class="audio"> <!--echo the audio file --> <ul class="playlist"> <li><a href="<?php echo"uploads/$podcast"; ?>"><?php echo"$noext_name"; ?></a></li> </ul> <!--<div id="sm2-container"> (I don't have an SM2 flash movie... but lets save this for later but for now I will comment out the div this is contained in also....) SM2 flash movie goes here </div> --> </td> <td> <div id="main"> <div id="left"> <span class='up'><a href="" class="vote" id="<?php echo $_SESSION['mes_id1']; ?>" name="up"><img src="up.png" alt="Down" /></a></span><br /> <?php echo $_SESSION['totalvotes1'] ?><br /> <!--<span class='down'><a href="" class="vote" id="<?php echo $mes_id1; ?>" name="down"><img src="down.png" alt="Down" /></a></span>--> </div> <div id="message"> <?php echo $_SESSION['message1'] ?> </div> <div class="clearfix"></div> </div> <div id="main"> <div id="left"> <!--<span class='up'><a href="" class="vote" id="<?php echo $mes_id2; ?>" name="up"><img src="up.png" alt="Down" /></a></span>--><br /> <?php echo $_SESSION['totalvotes2'] ?><br /> <span class='down'><a href="" class="vote" id="<?php echo $_SESSION['mes_id2']; ?>" name="down"><img src="down.png" alt="Down" /></a></span> </div> <div id="message"> <?php echo $_SESSION['message2'] ?> </div> <div class="clearfix"></div> </div> </td> </tr> </table> <br> <?php } ?> </div> up.php <?php session_start(); include("config.php"); $ip=$_SERVER['REMOTE_ADDR']; $ip_sql=mysql_query("select ip_add from Voting_IP where mes_id_fk='".$_SESSION['mes_id1']."' and ip_add='$ip'"); $count=mysql_num_rows($ip_sql); $ip_sql2=mysql_query("select ip_add from Voting_IP where mes_id_fk='".$_SESSION['mes_id2']."' and ip_add='$ip'"); $count2=mysql_num_rows($ip_sql2); if($count==0 && $count2!=0) { $sql = "update Messages set totalvotes=totalvotes+1 where mes_id='".$_SESSION['mes_id1']."'"; mysql_query( $sql); $sql_in = "insert into Voting_IP (mes_id_fk,ip_add) values ('".$_SESSION['mes_id1']."','$ip')"; mysql_query( $sql_in); $sql = "update Messages set totalvotes=totalvotes-1 where mes_id='".$_SESSION['mes_id2']."'"; mysql_query( $sql); $sql_in = "DELETE FROM Voting_IP WHERE mes_id_fk='".$_SESSION['mes_id2']."'"; mysql_query( $sql_in); } else if($count==0 && count2==0) { $sql = "update Messages set totalvotes=totalvotes+1 where mes_id='".$_SESSION['mes_id1']."'"; mysql_query( $sql); $sql_in = "insert into Voting_IP (mes_id_fk,ip_add) values ('".$_SESSION['mes_id1']."','$ip')"; mysql_query( $sql_in); } ?> config.php <?php $mysql_hostname = "localhost"; $mysql_user = "FoleyHurley"; $mysql_password = "******"; $mysql_database = "voting2"; $prefix = ""; $bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password) or die("Could not connect database"); mysql_select_db($mysql_database, $bd) or die("Could not select database"); ?>
  4. Hi, I have question about the PHP session. First, I have the site directory like this: -- root ---- classes -------- auth.php -------- curldata.php ---- includes -------- longin.php ---- index.php ---- dashboard.php ---- readapc.php The index.php has the login form: <form action="includes/login.php" method="post"> If login is successful, the login.php will do: require_once ("../classes/auth.php"); if ( success) { $_SESSION["logged"] = true; $_SESSION["user"] = array information // The user information array is returned from "auth.php". header("Location: ../dashboard.php"); } else header("Location: ../index.php"); In dashboard.php, it will display the $_SESSION['user'] data correctly. If clicking the link to readapc.php inside dashboard.php, the $_SESSION['user'] is good as well. The problem happened when I do the following code inside "readapc.php": (It is okay if I don't do this) require_once ("classes/curldata.php"); $result = data retrieved from curldata.php; $_SESSION['data'] = $result; If I do the things above, when I click the readapc.php, the session data is gone, readapc.php does NOT show $_SESSION['user'] data no more. (I am in readapc.php page now). But the $_SESSION['data'] is displayed well. Then, if I click dashboard.php link, it will jump to login page (index.php) because I setup if (!isset($_SESSION['logged'])) header("Location: index.php") on all index.php, dashboard.php, and readapc.php. Could anyone give me a hand on this problem? Thanks!
  5. Hi Everyone am having errors with this: Warning: Cannot modify header information - headers already sent by (output started at /------/--------/public_html/-------------------------.com/--------------------/classes/mobile.php:15) in /------/--------/public_html/-------------------------.com/--------------------/classes/mobile.php on line 6 Here is mobile.php <?php // line 1 // mobile.php // line 2 class mobile_redirection { // line 3 function __construct($pagename = NULL){ // line 4 if(preg_match('/(alcatel|amoi|android|avantgo|blackberry|benq|cell|cricket|docomo|elaine|htc|iemobile|iphone|ipad|ipaq|ipod|j2me|java|midp|mini|mmp|mobi|motorola|nec-|nokia|palm|panasonic|philips|phone|playbook|sagem|sharp|sie-|silk|smartphone|sony|symbian|t-mobile|telus|up\.browser|up\.link|vodafone|wap|webos|wireless|xda|xoom|zte)/i', $_SERVER['HTTP_USER_AGENT'])) { // line 5 if(isset($pagename)){ header('Location: http://www.----------------------------.com/mobile/'.$pagename); } else { header('Location: http://www.-------------------------------.com/mobile/'); } // line 6 } else { // line 7 return false; // line 8 } // line 9 } // line 10 } // line 11 ?> // line 13 I dont understand why there is an error on line fifteen as it doesn't exist and I dont know whats wrong on line 6. When someone goes to my domain it the index file the error comes up but what should happen is if they are a mobile they are redirected to a mobile sub directory or if they aren't a mobile they should be redirected to form.php. <?php // Login or Sign Up require('classes/mobile.php'); $mobile = new mobile_redirection('form.php'); if($mobile === false){ header('Location: form.php'); } ?> Any ideas why this isn't happening? Also, it isnt redirecting to form.php yet but if they get there and submit it will be using sessions: is it okay to use headers to redirect from 1.php to 2.php and then on 2.php start_session()? Thanks for reading and for any help in advance, Timothy
  6. I've come across a problem within (at least) Google Chrome and Safari. Upon the first attempt at logging in, the user is not redirected. The session is created, but it is almost as if it is not detected, and takes the user back to the index page. Upon a second attempt, the correct redirect is issued and the user is taken to the correct page. The script works fine in Firefox, and I have checked extensively to see if the correct data is being returned, which it is. I've searched and I've searched and I've searched, but unfortunately nothing of use has cropped up. Access.php - User logging in <?php session_start(); ob_start(); include_once('db.class.php'); include_once('register.class.php'); include_once('login.class.php'); $db = null; $reg = null; $log = null; $db = new Database(); $log = new Login($db, null, null, null, null, null, null); if (isset($_SESSION['login'])) { $log->redirectUser($_SESSION['login']); } include_once('includes/header.html'); ?> Some HTML... <?php if (isset($_POST['logsub'])) { $db = new Database(); $log = new Login($db, $_POST['email'], $_POST['pass']); $validation = &$log->validate(); if(empty($validation)) { $log->redirectUser($_SESSION['login']); } else { echo "<div id='error'><div class='box-error'><p style='font-weight: bold'>The following errors occured...</p><ul>"; for ($i = 0; $i < count($validation); $i++) { echo "<li>" . $log->getErrorMessage($validation[$i]) . "</li>"; } echo "</ul></div></div>"; } } ?> Login.class.php - Login class // Validate the credentials given public function validateLogin() { // Hash the plain text password $this->hashedPass = $this->hashPassword(); try { $query = $this->dbcon->prepare("SELECT Login_ID, Login_Email, Login_Password FROM Login WHERE Login_Email = :email AND Login_Password = :pass"); $query->bindParam(':email', $this->email, PDO::PARAM_STR); $query->bindParam(':pass', $this->hashedPass, PDO::PARAM_STR); $query->execute(); $fetch = $query->fetch(PDO::FETCH_NUM); $this->loginid = $fetch[0]; // If a match is found, create a session storing the login_id for the user if ($query->rowCount() == 1) { $_SESSION['login'] = $this->loginid; session_write_close(); } else { return LOG_ERR_NO_MATCH; } } catch (PDOException $e) { $this->dbcon->rollback(); echo "Error: " . $e->getMessage(); } } // Fetch the customer ID private function getCustId() { try { $query = $this->dbcon->prepare("SELECT Customer.Cust_ID FROM Customer JOIN Login ON Customer.Login_ID = Login.Login_ID WHERE Customer.Login_ID = :loginid"); $query->bindParam(':loginid', $this->loginid, PDO::PARAM_INT); $query->execute(); $fetch = $query->fetch(PDO::FETCH_NUM); return $fetch[0]; } catch (PDOException $e) { $this->dbcon->rollback(); echo "Error: " . $e->getMessage(); } } // Check the registration progress - are they verified? paid? // This function is used elsewhere hence the $sessionid argument public function checkRegistration($sessionid) { $this->loginid = $sessionid; $this->custid = $this->getCustId(); try { $queryVer = $this->dbcon->prepare("SELECT Cust_ID FROM Customer_Verify_Email WHERE Cust_ID = :custid"); $queryVer->bindParam(":custid", $this->custid, PDO::PARAM_INT); $queryVer->execute(); $queryFee = $this->dbcon->prepare("SELECT Cust_ID FROM Initial_Fee_Payment WHERE Cust_ID = :custid"); $queryFee->bindParam(":custid", $this->custid, PDO::PARAM_INT); $queryFee->execute(); // If a record exists in the verify table, return the value 1. This means the user has not yet verified their email. if ($queryVer->rowCount() == 1) { return 1; } else { // If a record does not exist in the payment table, no payment has been made. Return 2. if ($queryFee->rowCount() == 0) { return 2; // Otherwise, email is verified and the payment has been made. } else { return 0; } } } catch (PDOException $e) { $this->dbcon->rollback(); echo "Error: " . $e->getMessage(); } } // Redirect the user accordingly public function redirectUser($sessionid) { $this->loginid = $sessionid; $logNum = $this->checkRegistration($this->loginid); if ($logNum == 0) { header("Location: http://www.jonline.me.uk/fbedder/details.php", true, 200); exit(); } else if ($logNum == 1) { header("Location: http://www.jonline.me.uk/fbedder/verification.php", true, 200); exit(); } else if ($logNum == 2) { header("Location: http://www.jonline.me.uk/fbedder/payment.php", true, 200); exit(); } } Here's a link to the site: http://www.jonline.me.uk/fbedder/ -> I have set-up a test account with the credentials -> email: test@jonline.me.uk / password: test123321 To reiterate, the problem exists only in Google Chrome and Safari (the Safari being on my iPhone) and lies purely within the logging in aspect. On the first attempt, the session will be ignored (it is created), and on the second attempt, the user will be redirected. Any ideas? I've tried a multitude of possibilities... Thanks
  7. Hi everyone, I'm in the process of developing a site for my school which allows students and teachers to log in to do different things. At the moment I'm working on redirecting people from a page that requires them to be logged in as teachers. I've got a bit of code that works already which directs people away from the page and gives them a message. That code is here: <?php session_start(); if (empty($_SESSION['userName']) || $_SESSION['member_type'] == 'Student' ) { $_SESSION['msg'] = 'You must be a teacher to access the teachers.php page'; header("Location: login_required.php"); die(); } ?> However, I'd like to tweak this a bit so the message is customised, based on whether the person is: i) currently logged in as a student ii) not logged in at all iii) or else, if they're logged in as a teacher, simply displaying the page as normal. The code I've tried is this: <?php session_start(); if (empty($_SESSION['userName']) ) { $_SESSION['msg'] = 'You must be a teacher to access the teachers.php page. You are currently not logged in.'; header("Location: login_required.php"); die(); } else if ($_SESSION['member_type'] == 'Student'); { $_SESSION['msg'] = 'You are logged in as a student, but you must be a teacher to access the teachers.php page'; header("Location: login_required.php"); die(); } ?> This works by giving the correct messages to people who are either students or who are not logged in. However, if I am logged in as a teacher, I am still given the message saying "You are logged in as a student" etc...rather than having access to the page. I'd be greatly appreciative if anyone could point out my error. Thanks greatly, Dave
  8. Hey, I am trying to make a website with a back-end section for admin to updat the site without having to use html code. I have used this tutorial for the login portion: http://www.phpeasystep.com/phptu/6.html On my localhost everything works perfectly but when I upload this on my webspace there is an issue. Normally (localhost) when you want to go to admin.php (in the tutorial login_succesfull.php) and you have not logged in it will rederict you to the login page, but now it doesn't. If you go directly to the login.php and you enter the username and password it 'logs you in' and directs you to login_succesfull.php. I have updated all the info in checklogin.php to match the info from the webspace. I have no clue why it will work locally but not on a webspace, do you? ps: sorry for the bad english
  9. hello , im having some problem, and i did google alot and try different solution non have worked, ill try to give as much details as i can.. my code conatain some stuff like getting info from mysql DB , but i paste here only the part of code i have problem with. also i wrote this simple session code in my page just to make easy check on if it works. code: <?php session_start(); $_SESSION['test'] = "adam"; header('location: http://******.Index.php'); ?> now this code sit in a file called check.php and it called from an other php file contain form. now when the code run like this , and i move to page index.php the "echo $_SESSION['test'];" return empty. when i remove the header and put <a> tag link to index.php again "echo $_SESSION['test'];" return empty. when i remove the header totally, the call this code, and then write the link "www.****/.index.php" in the browser url bar , then echo $_SESSION['test']; return "adam" like it should... after looking on this problem on google, i try to add exit(0); after the header , that didnt work. also try to add session_write_close(); before the header , this also didnt work... any ideas??? thanks a head
  10. Hii I am trying to use the id of each student in the next page where it will be called to see their details... The code is shown below... <?php include('header.php'); ?> <div id="content"> <h1>Members</h1> <center><table width="550px"; class="table" cellspacing="10px" cellpadding="10px"> <tr> <td class="border">SL</td> <td class="border">Course Id</td> <td class="border">First Name</td> <td class="border">Last Name</td> <td class="border">Email</td> </tr> <?php $sl =1; $sql="SELECT student_id, course_id, student_fname, student_lname, student_email FROM student"; $result=mysql_query($sql); while($row=mysql_fetch_array($result)){ ?> <tr> <td class="border"><?php echo $sl; ?></td> <td class="border"><?php echo $row['course_id']; ?></td> <td class="border"><?php echo $row['student_fname']; ?></td> <td class="border"><?php echo $row['student_lname']; ?></td> <td class="border"><?php echo $row['student_email']; ?></td> <td class="border">[b][color=#ff0000]<a href="members_details.php?uid=<?php echo $row['student_id'];?>[/color][/b]">User Details</a></td> </tr> <?php $sl++; } ?> </table></center> </div> </div> </div> <?php include('footer.php'); ?> </body> </html> And the code where i want to show is <?php include('header.php'); ?> <?php [color=#ff0000][b]$uid=$_REQUEST['uid'];[/b][/color] $sql="SELECT * FROM student WHERE student_id='$uid'"; $result=mysql_query($result); while($row=mysql_fetch_array($result)){ ?> <div id="content"> <h1>Members</h1> <center><table width="550px"; class="table" cellspacing="10px" cellpadding="10px"> <tr> <td>First Name:</td> <td></td> </tr> <tr> <td>Last Name:</td> <td></td> </tr> <tr> <td>Email Id:</td> <td></td> </tr> <tr> <td>Phone No:</td> <td></td> </tr> <tr> <td>Gender</td> <td></td> </tr> <tr> <td>D.O.B</td> <td></td> </tr> <tr> <td>College:</td> <td></td> </tr> <tr> <td>State:</td> <td></td> </tr> <tr> <td>City:</td> <td></td> </tr> <tr> <td>Country:</td> <td></td> </tr> <tr> <td>Zip:</td> <td></td> </tr> </table></center> <?php } ?> </div> </div> </div> <?php include('footer.php'); ?> </body> </html> Where each blank <td></td> will be filled with their details queried from database... Plz help me out...
  11. I have worked up a login page and everything and works great, as well as on all the other pages set to if not logged in it will redirect to the login page. Code is here: <?php session_start(); if (!(isset($_SESSION['forteid']) && $_SESSION['forteid'] != '')) { header ("Location: login.php"); } ?> Now trying to add in certain pages where only certain access can access the page if not it will redirect back to the home page. This is what I have, but when not logged in and go to a page with this at the top, it just seems to skip over the first if (!isset) check: <?php session_start(); if (!(isset($_SESSION['forteid']) && $_SESSION['forteid'] != '')) { header ("Location: login.php"); } if (!(isset($_SESSION['accesslevel']) && $_SESSION['accesslevel'] != '1')) { header ("Location: noaccess.php"); } ?> I thought if else statement but not sure how to write that. Thanks for the help in advance!
  12. So I am new on using the SESSION variables in PHP. I have created a simple login screen. Not trying to be to secure with it, just wanted it to be a simple login so a certain field was filled in and the user cannot change the Rep field. Anyways, I have put this at the top of the page where it goes to when they login in the username and password are correct: <?php session_start(); if(isset($_SESSION['forteid'])) { header("location: index.php"); } else { header("location: login.php"); } ?> When I log in the page comes up with: This webpage has a redirect loop. The webpage at http://cslogs:8081/test/index.php has resulted in too many redirects. I am new with this so not sure how to fix this one or haven't found a way to attempt to fix it. Basically I want it to where they can't just type in http://cslogs:8081/test/index.php in the address bar and get to the screen without logging in, which the login page is just login.php. Thanks in advance.
  13. Hi, I am following the PHP Academy tutorial on youtube, and I'm on part 4 (http://www.youtube.com/watch?v=cJJKQ8MXGrE). However, I am running into a bit of a problem as I have other session variables for my user login and when I am using the foreach statement I dont want to include the login session variables if you understand, only the product_ variables function cart() { foreach($_SESSION as $name => $value) { if ($value>1) { if (substr($name, 0, =='product_'){ $id = substr($name, 8, (strlen($name)-); echo '<br />'.$id; } } else { echo "Your cart is empty! <br />"; echo $name.': has a value of :'.$value; } } } and this is displayed: As you can see it's also using the login session variables which is causing some issues for me because it's displaying that the cart is empty when it is not! So i'm a bit stuck as to what to do :S Sam-
  14. The website I am working on is a HRIS project for a popular fast food franchise chain. The login for one restaurant allows one user to modify all actions for all restaurants owned by the same franchisee. These are organized by multiple databases calling the same id's. Below is the code used for selecting all restaurants where the same franchise id is used as the restaurant login. $result = mysql_query("SELECT id, name FROM restaurants WHERE franchise = $_SESSION[sESS_RESTAURANT_FRANCHISE]"); $_SESSION['franchise_arr'] = array(); while($row = mysql_fetch_array($result)){ $_SESSION['franchise_arr'][$row['id']] = $row['name']; } So lets say for one login the SESSION array is populated like this: $_SESSION[sESS_RESTAURANT_FRANCHISE][1] = "Restaurant One"; $_SESSION[sESS_RESTAURANT_FRANCHISE][15] = "Restaurant Two"; $_SESSION[sESS_RESTAURANT_FRANCHISE][29] = "Restaurant Three"; I need a way to check to see if the KEY value is in an array as oppose to the value itself. For example I have: if (!in_array($rest, $_SESSION['franchise_arr'])){ $rest = $_SESSION['SESS_RESTAURANT_ID']; } However that checks for the values "Restaurant One", "Restaurant Two", "Restaurant Three". Where I would like it to look for "1", "15", or "29". I hope someone understands what I mean :\ I've been strugging with this for quite a while.
  15. I am new to php & have just tried to make a number guessing game using session. there is some problem in this code please help me !!! <?php session_start(); $count=0; if (isset ($_SESSION['counter'])) $count=$_SESSION['counter']; $count++; $a=rand(1,100); if (isset ($_SESSION['hide'])) $a=$_SESSION['hide']; if (isset ($_POST['number'])){ $ans=$_POST['number']; } else { $ans=-1; } if ($a==$ans){ echo " ","Your answer is correct !! Attempt= ", $count;}else { //var_dump($count); if ($count<4) { if (isset ($_POST['number'])){ echo $_POST['number']; if ($a<$ans){ echo " ","Your answer is greater.";} if ($a>$ans){ echo " ","Your answer is less.";} }}else { echo " ","<h4>Game Over !!</h4> The Correct Answer is ", $a;} } $_SESSION["counter"]=$count; $_SESSION["hide"]=$a; $_SESSION['counter']=''; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[url="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd%22>"]http://www.w3.org/TR...nsitional.dtd">[/url] <html xmlns="[url="http://www.w3.org/1999/xhtml%22>"]http://www.w3.org/1999/xhtml">[/url] <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Function</title> </head> <body> <form method="post"> <label> Guess Any Number (1 to 100) </label> <br /> <input type="text" name="number" value="<?php if (isset ($_POST['number'])) echo $ans; ?>" /> <br /><br /> <input type="submit" value="submit" name="submit" /> <br /> </form> <br /><br /> </body> </html>
  16. hi we've two kinds of clients, web client and an application which works as a client. now our application simulates web requests by calling index.php as the web client does. we want to change it to calling web services via nusoap. but there's a problem. web services are session-less. for example, a web service is called to authenticate. the second service when called has no sense about the authentication and it's completely a separate call. someone told me that i may put something eg. a hash code in http headers to include the data provided via authentication so that the next web services read the data from header and realize the call has been for what session. this way something like session simulation occurs. i'm not so familiar with 'http headers'. i don't know how can i do that. in the whole, i like to know what may be the best solution and whether nusoap keeps something internally like sessions so that i may read the in web services? what's your suggestion? thx
  17. Hello all, I read so much about it today and now i'm lost! I have a problem in somes pages of my website. For example, When a user registered on my web site, it redirect to a page to complete their profile, age, sexe, hubby,activity, and the user should enter a description in their word minimum 100 charactors... Sometime a user can stay in this page over than 30 minutes ..... so when they click on the button to save/create their profile, it's stop working because the max time for var session is reach, so the user is logged out automaticly and all the profile is lost.... so he/she needs to log in and do it again faster.... In read that by default, the time is set to 24 minutes.... how can i change it for 30 minutes or 40 minutes. Note that is inactive time.... the user is typing his description but he seam to enter in the inactive time.... How can i change it ? Thanks a lot!! Pascal
  18. Hey everyone, I am totally lost on this, I have a controller that is passed a parameter. This parameter is used to retrieve the contact information form the database. On a good return the controller will save the return a session variable. I can prove this by using print_r on the controller as well as when I am in the view. Now here is my problem, I have created a link using CI anchor which calls a different function within the same controller. When I try to call the variable it is no longer populated. I was wondering if I am not acknowledge how to use session variables correctly or if my understanding of how the function interact is a little flaky. here is the function that populates the sess variable $memDetail = $this->How_model->lookup($id); if(!$memDetail) { echo "member details are false "; // print_r($memDetail); } else { // echo "this is memDetai : "; // print_r($memDetail); $this->session->set_userdata('member_detail', $memDetail); print_r($this->session->all_userdata()); $this->load->view('view_lookup'); Let me know if you need any more information. Thank you in advance.
  19. Hi, I am writing some code to check logins to a mySQL database(WANIP) of remotes sites against usernames in wanipusers database. I have the login.php checking to see if there is a valid session, if not they are prompted to login, if there is a valid session, they are passed to login_success.php. Below is my login.php and the checklogin.php that checks for a valid session and the usernames against the wanipusers database. The login_success.php just gives them a choice to either update the database or add a new site. Currently, once they hit login.php, they are automatically sent to checklogin.php and the incorrect username message is displayed, once they click the return link to enter proper credentials, they are automatically sent to login_success.php, and that's not the way it's supposed to work. Any help would be appreciated, Thanks, Leonard **** login.php <?php session_start(); // Set timeout and kill session if necessary $inactive = 600; if (isset($_SESSION["timeout"])) { // calculate sessions TTL $sessionTTL = time() - $_SESSION["timeout"]; if ($sessionTTL > $inactive) { session_destroy(); header("Location: logout.php"); } } echo "<title>WANIP Login</title>"; if ($_SESSION["authorized"] = true) { header( 'Location: login_success.php' ) ; } else { $_SESSION["authorized"] = false; echo "<table width=300 border=0 align=center cellpadding=0 cellspacing=1 bgcolor=#CCCCCC><tr><form method=post action=checklogin.php><td><table width=100% border=0 cellpadding=3 cellspacing=1 bgcolor=#FFFFFF>"; echo "<tr>"; echo "<td colspan=3><strong>Login </strong></td></tr>"; echo "<tr><td width=78>Username</td><td width=6>:</td><td width=294><input name=myusername type=text id=myusername></td></tr><tr><td>Password</td><td>:</td><td><input name=mypassword type=password id=mypassword></td></tr><tr><td> </td><td> </td><td><input type=submit value=Login></td></tr></table></td></form></tr></table>"; echo "</center>"; echo "<center><a href=index.html>Return</a>"; } ?> **** checklogin.php <?php // Connect to server and select databse. mysql_connect("localhost", "user", "password")or die("cannot connect"); mysql_select_db("wanipusers")or die("cannot select DB"); // Define $myusername and $mypassword $username=$_POST['myusername']; $password=$_POST['mypassword']; echo "$username - $password"; // To protect MySQL injection (more detail about MySQL injection) $username = stripslashes($username); $password = stripslashes($password); $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); $sql="SELECT * FROM users WHERE username='$username' and password='$password'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $username and $password, table row must be 1 row if($count==1){ // Register $username, $password and redirect to file "login_success.php" session_register("username"); session_register("password"); header("location:login_success.php"); $_SESSION["authorized"] = true; } else { echo "<center>Incorrect Username and/or Password</center>"; echo "<center><a href=login.php>Return</a> and enter proper credetials</center>"; } ?>
  20. I have two seperate web app both written in php. one is a simple online store that needs users to be logged in and place their orders and the other one is a ticketing system that needs users to be logged in too. So how can I share a logged in session between these two apps to prevent users from multiple sign in process? what is the best way to do this? Thanks.
  21. Hello guys, it's my first post here.... Here is the code I got for now(changed the domain and subdomain names): <?php $agent = "Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16"; $headers = "Expect:"; $postdata = "username=test&password=test&ref=".base64_encode(md5(time().".com"))."&session=s".md5(time()); $login="http://subdomain.mydomain.com/login.php"; $grab="http://subdomain.mydomain.com/index.php"; function login($url,$data){ $fp = fopen("cookie.txt", "w"); fclose($fp); $login = curl_init(); curl_setopt($login, CURLOPT_COOKIEJAR, "cookie.txt"); curl_setopt($login, CURLOPT_COOKIEFILE, "cookie.txt"); curl_setopt($login, CURLOPT_TIMEOUT, 40000); curl_setopt($login, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($login, CURLOPT_URL, $url); curl_setopt($login, CURLOPT_USERAGENT, $agent); curl_setopt($login, CURLOPT_COOKIESESSION, true); curl_setopt($login, CURLOPT_FOLLOWLOCATION, TRUE); curl_setopt($login, CURLOPT_POST, TRUE); curl_setopt($login, CURLOPT_POSTFIELDS, $data); ob_start(); return curl_exec ($login); ob_end_clean(); curl_close ($login); unset($login); } function grab_page($site){ $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_USERAGENT, $agent); curl_setopt($ch, CURLOPT_TIMEOUT, 40000); curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt"); curl_setopt($login, CURLOPT_COOKIESESSION, true); curl_setopt($ch, CURLOPT_URL, $site); ob_start(); return curl_exec ($ch); ob_end_clean(); curl_close ($ch); } function grab_subpage($site){ $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_USERAGENT, $agent); curl_setopt($ch, CURLOPT_TIMEOUT, 40000); curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt"); curl_setopt($login, CURLOPT_COOKIESESSION, true); curl_setopt($ch, CURLOPT_URL, $site); ob_start(); return curl_exec ($ch); ob_end_clean(); curl_close ($ch); } function post_data($site,$data){ $datapost = curl_init(); curl_setopt($datapost, CURLOPT_URL, $site); curl_setopt($datapost, CURLOPT_TIMEOUT, 40000); curl_setopt($datapost, CURLOPT_HEADER, TRUE); curl_setopt($datapost, CURLOPT_HTTPHEADER, $headers); curl_setopt($datapost, CURLOPT_USERAGENT, $agent); curl_setopt($datapost, CURLOPT_POST, TRUE); curl_setopt($datapost, CURLOPT_POSTFIELDS, $data); curl_setopt($datapost, CURLOPT_COOKIEFILE, "cookie.txt"); ob_start(); return curl_exec ($datapost); ob_end_clean(); curl_close ($datapost); unset($datapost); } login($login, $postdata); echo grab_page($grab); ?> OK , so ... this code works fine if i navigate any page from http://subdomain.mydomain.com/ but if i try to grab a page from http://anothersubdomain.mydomain.com/ it drops and shows me a white page. var_dump(grab_page($grab)); echoes me string(0) "" . I can't figure out what is the problem and why I can't access that page. I'm googling for a week now and tryied tons of metods and nothing worked, maybe you guys can help me... Thanks in advance.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.