Mr_J Posted November 22, 2010 Share Posted November 22, 2010 Hi all, I have a site where the user must register to buy some products. After registration, you login and with the help of SESSIONS, you can view the page buynow.php. After the weekend, I opened the page and I got some yummy errors... Fatal error: Call to undefined function stop() in /home/pharmacz/public_html/ads/main_login.php on line 6 And line 6 reads: YES, BLANK... This is the php code: <?php session_start(); if(!session_is_registered(myusername)){ echo 'Please Login or Register'; } ?> I know I can use !isset... The register.php work fine Any Idea?? Link to comment https://forums.phpfreaks.com/topic/219435-php-endless-problems-please-help/ Share on other sites More sharing options...
Goldeneye Posted November 22, 2010 Share Posted November 22, 2010 session_is_registered is not a native PHP-function; that's most likely where the problem lies. Also, if myusername is supposed to be a variable, make sure you prepend a dollar-sign to it so it becomes: $myusername Link to comment https://forums.phpfreaks.com/topic/219435-php-endless-problems-please-help/#findComment-1137823 Share on other sites More sharing options...
revraz Posted November 22, 2010 Share Posted November 22, 2010 Maybe try <?php session_start(); if(!$_SESSION['myusername']) {echo 'Please Login or Register';} ?> But if that is broken, your pages that set the session are also broken. Did your host upgrade there PHP version? Link to comment https://forums.phpfreaks.com/topic/219435-php-endless-problems-please-help/#findComment-1137828 Share on other sites More sharing options...
Mr_J Posted November 22, 2010 Author Share Posted November 22, 2010 @Goldeneye I simply check the session and redirect to the login page. [myusername] is 100% valid session. Process.php: <?php $host="localhost"; // Host name $username=""; // Mysql username $password=""; // Mysql password $db_name=""; // Database name $tbl_name=""; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect to LOCALHOST"); mysql_select_db("$db_name")or die("cannot select DATABASE"); // username and password sent from form $myusername=$_POST['myusername']; $mypassword=md5($_POST['mypassword']); $myemail=$_POST['myemail']; // To protect MySQL injection $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myemail = stripslashes($myemail); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $myemail = mysql_real_escape_string($myemail); $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword' and email='$myemail'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file... session_register("myusername"); session_register("mypassword"); session_register("myemail"); header("location:buynow.php"); } else { echo 'Wrong Username or Password<br/><a href="javascript:history.go(-1)"><input type="button" value="Back">'; } ?> @revrazI will try the { } to echo. You know these fucking host peoples do just what they want and for the price I pay per month, I will work my way around the problem... Thanks... Link to comment https://forums.phpfreaks.com/topic/219435-php-endless-problems-please-help/#findComment-1137835 Share on other sites More sharing options...
Mr_J Posted November 22, 2010 Author Share Posted November 22, 2010 BTW, this is the only php in BUYNOW.php exept for the form rows etc.: <?php //hierdie kom in elke page wat net deur members gesien mag word session_start(); if(!session_is_registered(myusername)){ header("location:main_login.php"); } require_once( dirname(__FILE__).'/buy/form.lib.php' ); phpfmg_display_form(); function phpfmg_form( $sErr = false ){ $style=" class='form_text' "; ?> Link to comment https://forums.phpfreaks.com/topic/219435-php-endless-problems-please-help/#findComment-1137836 Share on other sites More sharing options...
revraz Posted November 22, 2010 Share Posted November 22, 2010 I showed you what code to change.. remove session_is_registered and use $_SESSION Link to comment https://forums.phpfreaks.com/topic/219435-php-endless-problems-please-help/#findComment-1137839 Share on other sites More sharing options...
Mr_J Posted November 22, 2010 Author Share Posted November 22, 2010 REVRAS Thank you, It works!! Link to comment https://forums.phpfreaks.com/topic/219435-php-endless-problems-please-help/#findComment-1137840 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.