Jump to content

cameeob2003

Members
  • Posts

    79
  • Joined

  • Last visited

    Never

Everything posted by cameeob2003

  1. All looked as though it would go well but now I have this error: [code] Parse error: parse error, unexpected $ in /homepages/34/d154144477/htdocs/ventgaming/n2p/loginscript/action.php on line 62[/code] If i remember right this happens when the session_start(); is not the first line of code so i put it as the first line but with no luck. So i then checked the other lines of code and from what I saw no errors were present. Is there an error Im missing? (Well obviously) The code: [code]<?php session_start(); header("Cache-control: private"); if ($_SESSION['auth'] = false) {        echo "Please login before tyring to access this area";     include("index.php"); /*you need to add some kind of if statement that will redirect users that are not loged in to the login page. You can change ['username'] to what ever you use for sessions*/ }else{ include("config/db.php"); function getpage($act) {     switch ($act) {         case "user_profile": $steamid = $_POST['steamid']; $handle = $_POST['handle']; $team_name = $_POST['team_name']; $team_tag = $_POST['team_tag']; # out with any unwanted characters $steamid = stripslashes($steamid); $handle = stripslashes($handle); $team_name = stripslashes($team_name); $team_tag = stripslashes($team_tag); # insert data into database $info2 = htmlspecialchars($info); $sql = mysql_query("UPDATE users SET steamid='$steamid', handle='$handle', team_name='$team_name', team_tag='$team_tag' WHERE id='$id'") or die (mysql_error()); if(!$sql){ echo '<font id=UserNameRed />There has been an error entering the data. Please contact the webmaster.'; }else{ echo '<font id=UserNameRed />The data was entered successfully.'; }         break;         case "add_news": $author = $_SESSION['user']; $title = $_POST['title']; $ndate = $_POST['date']; $news = $_POST['news']; # out with any unwanted characters $title = stripslashes($title); $ndate = stripslashes($ndate); $news = stripslashes($news); # insert data into database $description2 = htmlspecialchars($description); $sql = mysql_query("INSERT INTO news (date, author, title, news) VALUES ('$ndate','$author','$title','$news')") or die (mysql_error()); if(!$sql){ echo '<font id=UserNameRed />There has been an error entering the data. Please contact the webmaster.'; }else{ echo '<font id=UserNameRed />The data was entered successfully.'; } break;     } } getpage($_GET['act']);// this needs to be the same as the switch statement and the start of the function ?>[/code] I checked to make sure I had all the lines ended and it looks to be that way but i
  2. Everything you said worked fine for me using the echo command but here is another problem im having. It gives me an error when i put my script to execute the insertion of data to mysql database. Here is my code: [code]<?php session_start(); include("config/db.php");?> <?php function getpage($showpage) {     switch ($showpage) {         case "user_profile": $steamid = $_POST['steamid']; $handle = $_POST['handle']; $team_name = $_POST['team_name']; $team_tag = $_POST['team_tag']; # out with any unwanted characters $steamid = stripslashes($steamid); $handle = stripslashes($handle); $team_name = stripslashes($team_name); $team_tag = stripslashes($team_tag); # insert data into database $info2 = htmlspecialchars($info); $sql = mysql_query("UPDATE users SET steamid='$steamid', handle='$handle', team_name='$team_name', team_tag='$team_tag' WHERE id='$id'") or die (mysql_error()); if(!$sql){ echo '<font id=UserNameRed />There has been an error entering the data. Please contact the webmaster.'; }else{ echo '<font id=UserNameRed />The data was entered successfully.'; } } }         break;         case "add_news": // <<<<---- ERORR MESSAGE LINE 32 $author = $_SESSION['user']; $title = $_POST['title']; $ndate = $_POST['date']; $news = $_POST['news']; # out with any unwanted characters $title = stripslashes($title); $ndate = stripslashes($ndate); $news = stripslashes($news); # insert data into database $description2 = htmlspecialchars($description); $sql = mysql_query("INSERT INTO news (date, author, title, news) VALUES ('$ndate','$author','$title','$news')") or die (mysql_error()); if(!$sql){ echo '<font id=UserNameRed />There has been an error entering the data. Please contact the webmaster.'; }else{ echo '<font id=UserNameRed />The data was entered successfully.'; } } break;     } } getpage($_GET['act']); ?>[/code] Here is the error I get: [quote] Parse error: parse error, unexpected T_CASE in /homepages/34/d154144477/htdocs/ventgaming/n2p/loginscript/action.php on line 32[/quote]
  3. I am using the following code to try and get my page to display in an Iframe. Both of the following bits of code are on the same page called "index.php". When I click the link it redisplays the entire page html and all without showing the coded part. The problem I have: 1) the current page displays again in the Iframe without displaying the code I am trying to display This is what I want to happen: 1) for the code itself to display in the Iframe with no other content Here are the bits of code I am working with: Code that requests the ($_GET['page'] == "pagename") [code]<?php if(!$_SESSION['auth']){ echo '<form name="form1" method="post" action="login/checkuser.php"> <div style="position: absolute; top: 191px; left: 253px;"> <table><tr><td><font id=formtext />Username</td><td><input style="width: 100px; height= 12px;" name="username" type="text" id="username"></td></tr><tr> <td><font id=formtext />Password</td><td><input style="width: 100px; height= 12px;" name="password" type="password" id="password"></td><tr><td> <input style="position: absolute; top: 53px; left: 109px; background-image: url(img/login_button.gif); width: 51px; height: 15px; border: 0;" type="submit" name="Submit" value=""></td></tr></table> </div> </form>'; echo '<div style="position: absolute; top: 244px; left: 256px;"><a href="login/reg_form.html" target="frame1"><font id=bluesmall />Register</a></div>'; }else{ $newpms = $_SESSION['priv_messages']; echo '<div style="position: absolute; top: 191px; left: 253px;"><font id=UserNameRed />'. $_SESSION['username'] .'<br/><a href=?page=newpmessage=$id><font id=UserPanelText />Messages</a> ('. $newpms .')<br/><font id=UserPanelText /><a href=index.php?page=user_panel target=frame1>User Panel</a><br/> <a href="index.php?act=user_panel" target=frame1 > // <<<<---- the line that requests Logout</a><br/></div>'; } ?>[/code] The code the line requests to diplay: [code]<?php if($_GET['page'] == "user_panel"); echo "<font id=formtext />Welcome ". $_SESSION['first_name'] ." ". $_SESSION['last_name'] ."!<br /><br />"; echo "<font id=formtext />Your user level is<font id=UserNameRed /> ". $_SESSION['user_level']."<font id=formtext /> which enables     you access to the following areas: <br />"; if($_SESSION['user_level'] == 0){     echo "<br /><font id=UserNameRed />User Profile<br />"; } if($_SESSION['user_level'] == 1){     echo "- Forums<br />- Chat Room<br />- Moderator Area<br />"; } echo "<br /><a href=logout.php><font id=formtext />Logout</a>"; ?> [/code] Here is a picture of the problem: [url=http://n2p.ventgaming.com/problem/n2p1.jpg]http://n2p.ventgaming.com/problem/n2p1.jpg[/url]
  4. I am using the following script: [code] <?php session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>n2p - Nothing to Prove</title> <meta name="copyright" content="Copyright by psyche Design - All rights reserved." /> <meta name="page-type" content="Info" /> <link rel="stylesheet" href="n2p.css" type="text/css" /> </head> <body> <?php include("db.php"); $sql = "SELECT * FROM `users` order by `username`"; $result  = mysql_query($sql) or die(mysql_error()); while ($text = mysql_Fetch_array($result)) { $access = $text['access']; $handle = $text['handle']; } echo '<font id=UserNameBlue />User Panel<br/><br/>'; if($access == "0"){ echo "<font id=UserPanelText />Account Settings<br/> <font id=UserPanelText />User Profile<br/> <font id=UserPanelText />Mailbox<br/><br/> <font id=UserPanelText />Make Donation<br/>"; } if($access == "1"){ echo "<font id=UserPanelText />Account Settings<br/> <font id=UserPanelText />User Profile<br/> <font id=UserPanelText />Mailbox<br/> <font id=UserPanelText />Edit Media<br/>"; } if($access == "2"){ echo "<font id=UserPanelText />Account Settings<br/> <font id=UserPanelText />User Profile<br/> <font id=UserPanelText />Mailbox<br/> <font id=UserPanelText />Edit Media<br/> <font id=UserPanelText />Edit Matches<br/>"; } if($access == "3"){ echo "<font id=UserPanelText />Account Settings<br/> <font id=UserPanelText />User Profile<br/> <font id=UserPanelText />Mailbox<br/> <font id=UserPanelText />Edit Media<br/> <font id=UserPanelText />Edit Matches<br/> <font id=UserPanelText />Edit Forums<br/>"; } if($access == "4"){ echo "<font id=UserPanelText />Account Settings<br/> <font id=UserPanelText />User Profile<br/> <font id=UserPanelText />Mailbox<br/> <font id=UserPanelText />Edit Media<br/> <font id=UserPanelText />Edit Matches<br/> <font id=UserPanelText />Edit Forums<br/> <font id=UserPanelText />Edit Sponsors<br/>"; } if($access == "5"){ echo "<font id=UserPanelText />Account Settings<br/> <font id=UserPanelText />User Profile<br/> <font id=UserPanelText />Mailbox<br/> <font id=UserPanelText />Edit Media<br/> <font id=UserPanelText />Edit Matches<br/> <font id=UserPanelText />Edit Forums<br/> <font id=UserPanelText />Edit Sponsors<br/> <font id=UserPanelText />Edit Proshop<br/>"; } if($access == "6"){ echo "<font id=UserPanelText />Account Settings<br/> <font id=UserPanelText />User Profile<br/> <font id=UserPanelText />Mailbox<br/> <font id=UserPanelText />Edit Media<br/> <font id=UserPanelText />Edit Matches<br/> <font id=UserPanelText />Edit Forums<br/> <font id=UserPanelText />Edit Sponsors<br/> <font id=UserPanelText />Edit Proshop<br/> <font id=UserPanelText />Edit Roster<br/>"; } ?> </body> </html>[/code] And I get the following error: [quote] Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0[/quote] Why is this?
  5. Yes and im not sure where or how I would go about this. I want to click the button and have it add the $id to the end automatically. Im sorry I may be annoying but its just I realy want to learn this stuff I find it fun and enjoyable.
  6. sorry im just looking for an explination on how to get this to work were it goes to [url=http://domain/file.php?act=delete&delete_news=1]http://domain/file.php?act=delete&delete_news=1[/url] instead of the not functioning -.^
  7. I am not sure why this wont delete the actuall posting from the mysql database I have reviewed several websites and different forums to find the answer to my knowldge it is as it should be. The only problem is when I go to delete the post it says deleted and will not delete the post. Here is the code im using to do so: [code]<?php session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>n2p - Nothing to Prove</title> <link rel="stylesheet" href="n2p.css" type="text/css" /> </head> <body> <?php include("db.php"); if($_GET['act'] == "delete"){ //include database files $id = $_GET['delete_news']; $sql = mysql_query("DELETE FROM news WHERE id='$id'") or die (mysql_error()); if(!sql){ echo "Could not delete news post."; }else{ echo "News post deleted."; } } ?> <form method="post" name="delete_old_news" action="?act=delete"> <table> <tr> <td> <select name="news_posts"> <?php // Delete Highlight Match $sql = "SELECT * FROM `news` order by `id`"; $result  = mysql_query($sql) or die(mysql_error()); while ($text = mysql_Fetch_array($result)) { $id = $text['id']; $title = $text['title']; $ndate = $text['date']; echo '<option name="delete_news" value="'.$id.'">'. $title .' '. $ndate .'</option><br/>';} ?> </select> </td> </tr> <td><input name="submit" type="submit" value="submit" /></td></tr> </table> </form> </body> </html> [/code] If someone could explain why this isnt working to me that would be great im realy wanting to learn the reson why.
  8. So how do I get the: "page.php?act=del&id=" portion to add the &id= part? Im not realy sure of this an explination or tutorial area on this would be great I would google it but im not sure how to define it.
  9. Well what format would I put it in since im not realy that great at php and in a rush tofinish this section?
  10. Would I set it in that way by the following: [code] if($_GET['act'] == "edit_matches&delete_recent_match"){ $id = $_GET["edit_recent_match2"];     $query = mysql_query("DELETE FROM recent_match WHERE id='$id'") or die (mysql_error()); if(!$query){ echo '<font id=UserNameRed />There has been an error deleting the data. Please contact the webmaster.'; }else{ echo '<font id=UserNameRed />The data was deleted successfully.'; } }[/code]
  11. I am having trouble getting this to work when ever I try to have the following script run: [code]if($_GET['act'] == "delete_recent_match"){ $id = $_GET["edit_recent_match2"];     $query = "DELETE FROM recent_match WHERE id='$id'"; mysql_query($query) or die (mysql_error()); if(!$query){ echo '<font id=UserNameRed />There has been an error deleting the data. Please contact the webmaster.'; }else{ echo '<font id=UserNameRed />The data was deleted successfully.'; } }[/code] I get this in the browser address: [quote]http://mysite.com/delete_recent_match_proc.php?delete_recent_match=1&submit=submit[/quote] I know its because this page is on the same page as the file from where in trying to execute it but why does it go to the "&submit=submit" line?? Im not sure of what I should do to correct this.
  12. here is my login.php [code]<?php $user = $_POST['username']; $pass = $_POST['password']; $user=str_replace(" ","",$user);//remove spaces from username $pass=str_replace(" ","",$pass);//remove spaces from password $user=str_replace("%20","",$user);//remove escaped spaces from username $pass=str_replace("%20","",$pass);//remove escaped spaces from password $user=addslashes($user);//remove spaces from username $pass=addslashes($pass);//remove spaces from password // connect to mysql db $conn = mysql_connect("db411.perfora.net","dbo168663394","w.N6n7gG"); mysql_select_db("db168663394"); $request = "SELECT * FROM users WHERE password='".$pass."' AND username='".$user."'"; $results = mysql_query($request,$conn); if(mysql_num_rows($results))//function returns true if any matches are found { echo "User Logged in."; $_SESSION['user'] = $user; $_SESSION['auth'] = true; include("index2.php"); } else { echo "User Name/Password Not Found."; $_SESSION['auth'] = false; include("index.php"); } ?>[/code]
  13. no i am not calling anything before it. it is just: [code]<html><body> <div style="position: absolute; top: 191px; left: 260px;"> <?php session_start(); if(!$_SESSION['user']){ echo "<font id=UserPanelText />You are not logged in.<br/><br/>"; }else{ echo "You are logged in as:". $_SESSION['username'] ."<br/><br/>"; } $newpms = $_SESSION['priv_messages']; if($newpms > "0"){ echo "<a href=?page=newpmessage=$id>Unread Messages</a> (". $newpms .")<br/>"; }else{ echo "<font id=UserPanelText /><a href=?page=pmessages=$id>Mailbox</a><br/><font id=UserPanelText /><a href=?page=user_panel>User Panel</a><br/>"; } ?> </div> </body> </html>[/code]
  14. I am getting the following errors: [quote]Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /homepages/34/d154144477/htdocs/ventgaming/n2p/login.php:22) in /homepages/34/d154144477/htdocs/ventgaming/n2p/index2.php on line 224[/quote] I was wondering what this error is caused from. I read on a dif forum that it can be from spaces outside of code but I have none and still recieve this error.
  15. I got help from a friend :P and yes code was very bad had alot of revision to do to it.
  16. I am trying to allow my users to login to the site 1 time and then not have to login again until they have closed the window. I am using the following script wich I found on this site as a tutorial and have modified to authenticate my users: login.php [code]<?php session_start(); header("Cache-control: private"); $user = $_POST['username']; $pass = $_POST['password']; include("db.php"); // Check to see if the user exists. $sql_user_check = "SELECT username FROM users WHERE username='$user'"; $result_name_check = mysql_query($sql_user_check) or die(mysql_error()); $usersfound = mysql_num_rows($result_name_check) or die(mysql_error()); // If the user is not found note that and end. if($usersfound < 1){ $error = "User ".$user." was not found in the database."; $user = $_POST['username']; $pass = md5($_POST['password']); $sql = "select * from users where `username` = '$user'"; $result = mysql_query($sql); while ($text = mysql_fetch_array($result)) { $id = $text['id']; $password = $text['encrytpass']; $access = $text['access']; } if ($pass == $password) { $error = "Wrong Username / Password <a href=\"?act=login\">Back</a>"; // If the passwords do match, let in and go to the session variables. }else{ $_SESSION['userid'] = $text['userid']; $_SESSION['first_name'] = $text['first_name']; $_SESSION['last_name'] = $text['last_name']; $_SESSION['username'] = $text['username']; $_SESSION['password'] = $text['password']; $_SESSION['encryptpass'] = $text['encryptpass']; $_SESSION['email'] = $text['email']; $_SESSION['location'] = $text['location']; $_SESSION['steamid'] = $text['steamid']; $_SESSION['handle'] = $text['handle']; $_SESSION['bio'] = $text['bio']; $_SESSION['photo'] = $text['photo']; $_SESSION['team_name'] = $text['team_name']; $_SESSION['team_tag'] = $text['team_tag']; $_SESSION['access'] = $text['access']; $_SESSION['webs'] = $text['webs']; $_SESSION['priv_message'] = $text['priv_message']; } } if(!$_SESSION['username']){ if($error){ echo $error; include("index.php"); }else{ header("Location: index2.php");   }     }else{ echo "<html><head><title>Welcome Back</title></head>Welcome back ". $_SESSION['username'] .".<a href=index2.php>Click here</a> to proceed."; } ?>[/code] here is the code I am using on index2.php to display information if the user is logged in: [code]<?php session_start(); if(!$_SESSION['username']){ echo "You are logged in as:". $_SESSION['username'] ."<br/><br/>"; }else{ echo "<font id=UserPanelText />You are not logged in.<br/><br/>"; } $newpms = $_SESSION['priv_messages']; if($newpms > "0"){ echo "<a href=?page=newpmessage=$id>Unread Messages</a> (". $newpms .")<br/>"; }else{ echo "<font id=UserPanelText /><a href=?page=pmessages=$id>Mailbox</a><br/><font id=UserPanelText /><a href=?page=user_panel>User Panel</a><br/>"; } ?> </div> <div style="position: absolute; top: 225; left: 780;"> <?php include("db.php"); $sql = "SELECT * FROM `matches` order by `id` DESC LIMIT 0,3";   $result    = mysql_query($sql) or die(mysql_error());   $num    = mysql_num_rows($result);   while ($text = mysql_Fetch_array($result)) { $id = $row['id']; $team1 = $row['home_team']; $team2 = $row['away_team']; $score1 = $row['score_one']; $score2 = $row['score_two']; $sql2 = "SELECT $id FROM `matches` WHERE `id`='$id'order by `id` DESC LIMIT 0,3"; $result2    = mysql_query($sql2) or die(mysql_error()); $num2    = mysql_num_rows($result2); echo ' <tr><td> $id </td><td height="18" width=35 valign="bottom" align="left"><font id=ctext />n2p <font id=dash />vs<font id=ttext /> $team2 </td><td width="34" height=18 align="right" valign="bottom"><font id=ctext /> $score1 <font id=dash />-<font id=ttext /> $score2 </td></tr>'; } ?>[/code] I am getting the not logged in message even though I beleive I have set the users sessions correctly. I have tried everything I can in my limited knowledge of php and also have searched google with no results. here is an example of what is happening. [url=http://n2p.ventgaming.com]http://n2p.ventgaming.com[/url] user: test pass: test
  17. Here is my error: [quote]You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '.')' at line 1[/quote] Im not quite sure where it is here are my scripts im using: db.php [code]<?php # Database connect script # You can edit the next four lines $db_host = 'db411.perfora.net'; $db_user = 'dbo168663394'; $db_pass = 'w.N6n7gG'; $db_name = 'db168663394'; # Under here DONT TOUCH!!! $connection = mysql_pconnect("$db_host","$db_user","$db_pass") or die("Couldn't connect to server"); $db = mysql_select_db("$db_name", $connection) or die("Couldn't select database"); ?>[/code] edit_match.php [code] <?php include("db.php"); # get variables $game = $_POST['game']; $opponent = $_POST['opponent']; $score1 = $_POST['score1']; $score2 = $_POST['score2']; $date = $_POST['date']; $league = $_POST['league']; $map = $_POST['map']; $description = $_POST['description']; # out with any unwanted characters $game = stripslashes($game); $opponent = stripslashes($opponent); $score1 = stripslashes($score1); $score2 = stripslashes($score2); $date = stripslashes($date); $league = stripslashes($league); $map = stripslashes($map); $description = stripslashes($description); if((!$opponent) || (!$map) || (!$description)){ echo "The following are required to fields:<br/>"; if(!$opponent){ echo "Opponent name<br/>"; } if(!$map){ echo "Map<br/>"; } if(!$desciption){ echo "Description<br/>"; } include("edit_matches.html"); exit(); } # insert data into database $description2 = htmlspecialchars($description); $sql = mysql_query("INSERT INTO matches (game, opponent, score_one, score_two, date, league, map, description) VALUES ('$game','$opponent','$score1','$score2','$date','$league','$map','$description2')") or die (mysql_error()); if(!$sql){ echo 'There has been an error entering the data. Please contact the webmaster.'; }else{ echo 'The data was entered successfully.'; } ?>[/code]
  18. I make the mention of conversion here in line 96: [code]# everything checks out so far, so lets add the user! $db_password = md5($pass1);[/code]
  19. Im not sure why I am getting this error but I only get it when trying to transfer sessions from 1 page to another i believe. Im not positive its the sessions but I think it could be. Im not the greatest at php yet so I am posting my scripts here to see what the experts say I should do to fix this problem. Problem/error: [code]Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)[/code] Scripts: login.php [code]<?php session_start(); header("Cache-control: private"); $user = $_POST['username']; $pass = $_POST['password']; include("db.php"); // Check to see if the user exists. $sql_user_check = "SELECT username FROM users WHERE username='$user'"; $result_name_check = mysql_query($sql_user_check) or die(mysql_error()); $usersfound = mysql_num_rows($result_name_check) or die(mysql_error()); // If the user is not found note that and end. if($usersfound < 1){ $error = "User ".$user." was not found in the database."; $user = $_POST['username']; $pass = md5($_POST['password']); $sql = "select * from users where `username` = '$user'"; $result = mysql_query($sql); while ($text = mysql_fetch_array($result)) { $id = $text['id']; $password = $text['encrytpass']; $access = $text['access']; } if ($pass == $password) { $error = "Wrong Username / Password <a href=\"?act=login\">Back</a>"; // If the passwords do match, let in and go to the session variables. }else{ $_SESSION['userid'] = $text['userid']; $_SESSION['first_name'] = $text['first_name']; $_SESSION['last_name'] = $text['last_name']; $_SESSION['username'] = $text['username']; $_SESSION['password'] = $text['password']; $_SESSION['encryptpass'] = $text['encryptpass']; $_SESSION['email'] = $text['email']; $_SESSION['location'] = $text['location']; $_SESSION['steamid'] = $text['steamid']; $_SESSION['handle'] = $text['handle']; $_SESSION['bio'] = $text['bio']; $_SESSION['photo'] = $text['photo']; $_SESSION['team_name'] = $text['team_name']; $_SESSION['team_tag'] = $text['team_tag']; $_SESSION['access'] = $text['access']; $_SESSION['webs'] = $text['webs']; $_SESSION['priv_message'] = $text['priv_message']; } } if(!$_SESSION['username']){ if($error){ echo $error; include("index.php"); }else{ header("Location: index2.php");   }     }else{ echo "<html><head><title>Welcome Back</title></head>Welcome back ". $_SESSION['username'] .".<a href=index2.php>Click here</a> to proceed."; } ?>[/code] index2.php [code]<?php session_start(); header("Cache-control: private"); if($_SESSION['username']){ echo "You are logged in as:". $_SESSION['username'] ."<br/><br/>"; }else{ echo "<font id=UserPanelText />You are not logged in.<br/><br/>"; } $newpms = $_SESSION['priv_messages']; if($newpms > "0"){ echo "<a href=?page=newpmessage=$id>Unread Messages</a> (". $newpms .")<br/>"; }else{ echo "<font id=UserPanelText /><a href=?page=pmessages=$id>Mailbox</a><br/><font id=UserPanelText /><a href=?page=user_panel>User Panel</a><br/>"; } ?>[/code]
  20. Here is my register script pretty simple. register.php [code]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>n2p - Nothing to Prove</title> <meta name="copyright" content="Copyright by psyche Design - All rights reserved." /> <meta name="page-type" content="Info" /> <link rel="stylesheet" href="n2p.css" type="text/css" /> <?php # include mysql connection script include 'db.php'; # Grab the post variables from the PHP form $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $email = $_POST['email']; $username = $_POST['username']; $pass1 = $_POST['pass1']; $pass2 = $_POST['pass2']; $bio = $_POST['bio']; # Make sure passwords match if ($_POST['pass1'] == $_POST['pass2']){       $password = TRUE;     } else {       $password = FALSE;       echo '<p>Your password did not match the confirmed password!</p>';   } $legit = ereg("^[a-zA-Z0-9]{8,15}$", $pass1); if(!legit){ $error = "Your password was to long or in the wrong format. Please make your password between 8-15 characters long and only contain numbers and letters."; } # Checking for anything that could cause errors $first_name = stripslashes($first_name); $last_name = stripslashes($last_name); $email = stripslashes($email); $username = stripslashes($username); $pass1 = stripslashes($pass1); $pass2 = stripslashes($pass2); $bio = stripslashes($bio); # Any errors in the posted fields? Lets check... if((!$first_name) || (!$last_name) || (!$email) || (!$username) || (!$pass1) || (!$pass2)){ echo 'You did not submit the following required information! <br/>'; if(!$first_name){ echo '<font id=UserNameRed />First name <font id=UserPanelText />is a required field. Please enter it below. <br/>'; } if(!$last_name){ echo '<font id=UserNameRed />Last name <font id=UserPanelText />is a required field. Please enter it below. <br/>'; } if(!$email){ echo '<font id=UserNameRed />Email address <font id=UserPanelText />is a required field. Please enter it below. <br/>'; } if(!$username){ echo '<font id=UserNameRed />Username <font id=UserPanelText />is a required field. Please enter it below. <br/>'; } if(!$pass1){ echo '<font id=UserNameRed />Password <font id=UserPanelText />is a required field. Please enter it below. <br/>'; } if(!$pass2){ echo '<font id=UserNameRed />Password(again) <font id=UserPanelText />is a required field. Please enter it below. <br/>'; } include("register_form.html"); exit(); } # does this username already exist in the database? lets check for that now... $sql_email_check = mysql_query("SELECT email FROM users WHERE email='$email'"); $sql_username_check = mysql_query("SELECT username FROM users username='$username'"); $email_check = mysql_num_rows($sql_email_check); $username_check = mysql_num_rows($sql_username_check); if(($email_check > 0) || ($username_check > 0)){ echo 'Please fix the following errors: <br/>'; if($email_check > 0){ echo '<strong>Your email address has already been used by another member in our database. Please use a different Email address!<br/>'; unset($email); } if($username_check > 0){ echo 'The username you have selected has already been used by another member in our database. Please choose a different Username!<br/>'; unset($username); } include("register_form.html"); // Show form again exit(); } # everything checks out so far, so lets add the user! $db_password = md5($pass1); # Enter into database $bio2 = htmlspecialchars($bio); $sql = mysql_query("INSERT INTO users (first_name, last_name, email, username, password, encryptpass, bio) VALUES ('$first_name','$last_name','$email','$username','$pass1','$$db_password','$bio2')") or die (mysql_error()); if(!$sql){ echo 'There has been an error creating your account. Please contact the webmaster.'; }else{ echo 'Your account has been successfully registered. You may now login.'; } ?> </head> </html>[/code]
  21. Here is my full code working: [code]<?php session_start(); header("Cache-control: private"); $user = $_POST['username']; $pass = $_POST['password']; include("db.php"); // Check to see if the user exists. $sql_user_check = "SELECT username FROM users WHERE username='$user'"; $result_name_check = mysql_query($sql_user_check) or die(mysql_error()); $usersfound = mysql_num_rows($result_name_check) or die(mysql_error()); // If the user is not found note that and end. if($usersfound < 1){ $error = "User ".$user." was not found in the database."; $user = $_POST['username']; $pass = md5($_POST['password']); $sql = "select * from users where `username` = '$user'"; $result = mysql_query($sql); while ($text = mysql_fetch_array($result)) { $id = $text['id']; $password = $text['encrytpass']; $access = $text['access']; } if ($pass == $password) { $error = "Wrong Username / Password <a href=\"?act=login\">Back</a>"; // If the passwords do match, let in and go to the session variables. }else{ $_SESSION['userid'] = $user_info['userid']; $_SESSION['first_name'] = $user_info['first_name']; $_SESSION['last_name'] = $user_info['last_name']; $_SESSION['username'] = $user_info['username']; $_SESSION['password'] = $user_info['password']; $_SESSION['encryptpass'] = $user_info['encryptpass']; $_SESSION['email'] = $user_info['email']; $_SESSION['location'] = $user_info['location']; $_SESSION['steamid'] = $user_info['steamid']; $_SESSION['handle'] = $user_info['handle']; $_SESSION['bio'] = $user_info['bio']; $_SESSION['photo'] = $user_info['photo']; $_SESSION['team_name'] = $user_info['team_name']; $_SESSION['team_tag'] = $user_info['team_tag']; $_SESSION['access'] = $user_info['access']; $_SESSION['webs'] = $user_info['webs']; $_SESSION['priv_message'] = $user_info['priv_message']; } } if(!$_SESSION['username']){ if($error){ echo $error; include("index.php"); }else{ echo "You are logged in."; include("index2.php");   }     }else{ echo "<html><head><title>Welcomce Back</title></head>Welcome back ". $_SESSION['username'] .".<a href=index2.php>Click here</a> to proceed."; } ?>[/code] As far as I know it works but how do I get it to check if all the $_SESSION[''];'s registered? And are working cuz when I use the start_session(); command it gives me an error saying that Im not logged in even though my login script has authed me. Is there something I need to do to keep the session open on a new page besides what I did in the following code. [code]<?php session_start(); header("Cache-control: private"); if(!$_SESSION['username']){ echo "<font id=UserPanelText />You are not logged in."; exit(); } $newpms = $_SESSION['priv_messages']; echo "You are logged in as:". $_SESSION['username'] ."<br/><br/>"; if($newpms > "0"){ echo "<a href=?page=newpmessage=$id>Unread Messages</a> (". $newpms .")<br/>"; }else{ echo "<font id=UserPanelText />No unread messages. --<a href=?page=pmessages=$id>Mailbox</a><br/><font id=UserPanelText /><a href=?page=user_panel>User Panel</a><br/>"; } ?>[/code]
×
×
  • 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.