stem Posted December 19, 2006 Share Posted December 19, 2006 Well obviously i need help i'm in the help forum :Dthe problem is...i have a webpage that i have made... and i want some members of my site to be able to edit it but not others... but i don't want to give them members access to the Cpanel..Is there a way of creating a login system that allows the user to change and save the page?i want them to be able to edit the information within this table:http://www.habboboom.co.uk/community/events.phpAnyideaS?thanksstem Link to comment https://forums.phpfreaks.com/topic/31246-need-help/ Share on other sites More sharing options...
chiprivers Posted December 19, 2006 Share Posted December 19, 2006 Create a simple user login system (there are many thread detailing this), add an extra column in your table that contains a access_auth level. You can then give different users different levels of access. Link to comment https://forums.phpfreaks.com/topic/31246-need-help/#findComment-144535 Share on other sites More sharing options...
stem Posted December 19, 2006 Author Share Posted December 19, 2006 I'm a complete noobie at php...although i have eddited some php,and i've looked and couldn't find anything could you please point me in the right direction? Link to comment https://forums.phpfreaks.com/topic/31246-need-help/#findComment-144537 Share on other sites More sharing options...
craygo Posted December 19, 2006 Share Posted December 19, 2006 You would probably use sessions to have there login. you have to do some things.1. Create a database or table in your database which holds your usershere is an sql of my table structure[code]CREATE TABLE `users` ( `id` int(11) unsigned NOT NULL auto_increment, `username` varchar(50) NOT NULL default '', `password` varchar(50) NOT NULL default '', `ugroup` varchar(25) NOT NULL default '0', `lastlogin` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`id`)) ENGINE=MyISAM;[/code]2. create form to add users to table preferably with md5 hashing for the password3. Create login form with session so user with access can only view the pagesI am not sure what you mean by update a page. In order to do something like that you would have to have a html page show up in a text area for editing. My preference would be to create a php template which pulls information from a table. that way you can just let the user edit the table and the values are plugged into the template when viewed.EDIT: i just looked at your page and you can hold the events in a table and have php pull the info from the table and populate the page, that way users just need to have access to add/edit events.Ray Link to comment https://forums.phpfreaks.com/topic/31246-need-help/#findComment-144544 Share on other sites More sharing options...
stem Posted December 19, 2006 Author Share Posted December 19, 2006 [quote author=craygo link=topic=119260.msg488272#msg488272 date=1166545801]2. create form to add users to table preferably with md5 hashing for the password3. Create login form with session so user with access can only view the pages i just looked at your page and you can hold the events in a table and have php pull the info from the table and populate the page, that way users just need to have access to add/edit events.Ray[/quote]It confuses me a little...i am really a complete noob :(I know how to build a Mysql table but the rest i'm completely oblivious too Link to comment https://forums.phpfreaks.com/topic/31246-need-help/#findComment-144576 Share on other sites More sharing options...
craygo Posted December 19, 2006 Share Posted December 19, 2006 Post your code for you current page and I will help outRay Link to comment https://forums.phpfreaks.com/topic/31246-need-help/#findComment-144625 Share on other sites More sharing options...
stem Posted December 19, 2006 Author Share Posted December 19, 2006 So far i have:install.php - where i add users to the database that you posted[code]<head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Sign up</title></head><body><form id="form1" name="form1" method="post" action=""> <table width="143" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <th scope="col">Username:</th> </tr> <tr> <td><label> <input type="text" name="username" id="username" /> </label></td> </tr> <tr> <th>Password:</th> </tr> <tr> <td><label> <input type="password" name="password" id="password" /> </label></td> </tr> <tr> <th>Group:</th> </tr> <tr> <td><label> <div align="center"> <select name="ugroup"> <option value="1">Admin</option> <option value="2">Staff</option> <option value="3" selected="selected">Trainee</option> </select> </div> </label></td> </tr> </table></form></body></html>[/code]--------------------------------------------and my events page events.php[code]<html><head><title>HabboBoom ~ Events</title></head><!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"><meta name="Description" content="HabboBoom is a ever exspanding Habbo Hotel Uk Unoffical fansite which is hoping to become Offical in the near further" /><meta name="Keywords" content="HabHabbo HotelHabboHabbo FansitesHabbo sitesHabbo Community<br />HabboBoom<br />HB<br />Habbo Radio<br />Habbo Boom" /><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><style>a.navilinks:link {text-decoration:none;font-weight:bold;}a.navilinks:link {text-decoration:none;font-weight:bold;}a.navilinks:link {text-decoration:none;font-weight:bold;}a.navilinks:hover {text-decoration:none;font-weight:bold;}body,td,th { font-family: Verdana; font-size: 10px; color: #CCCCCC;}body { background-image: url(background.PNG);}.option{cursor:pointer;color:#000000;text-decoration:none;}a:link { color: #00CCFF; text-decoration: none;}a:visited { color: #00CCFF; text-decoration: none;}a:hover { color: #006699; text-decoration: underline;}a:active { color: #00CCFF; text-decoration: none;}a { font-weight: bold;#Layer1 { position:absolute; width:300px; height:300px; z-index:5;}#Layer1 { position:absolute; width:75; height:86; z-index:5; left: 904px; top: 7px;}.style3 {font-size: 9px; }.style4 {font-size: 9px; font-family: Verdana, Arial, Helvetica, sans-serif; }.style6 {font-family: Verdana, Arial, Helvetica, sans-serif; }</style></head><body><center><p> </p><p> </p><p><br /> <br /></p><table width="629" height="29" border="0" cellspacing="0"> <tr> <td height="29" background="/images/Images/MB/top.gif"> </td> </tr> <tr> <td background="/images/Images/MB/middle.gif"><blockquote><b>Dear Habbo, <blockquote></b> <p align="left"><div><img width="246" height="21" src="/events_logo.gif" alt="" title=""> <font size="1"><br><br><font face="Verdana">Welcome to the Events area of HabboBOOM!</font></font></div><div><font size="1"><font face="Verdana">We have taken the time to plan events, for all you lovely habbos!</font></font></div><div><font size="1"><font face="Verdana">Below are the planned events!! </font></font></div><br><br><br><img style="margin: 0px;" width="49" height="96" align="right" src="/tele_ani.gif" alt="" title=""><br><table style="border-collapse: collapse;" width="436" cellspacing="0" cellpadding="3" bordercolor="#000000" border="0" bgcolor="#79cdcd"><tbody><tr><td width="33%" valign="top"><div><font color="#660066"><strong>Event Host </strong></font></div></td><td width="33%" valign="top"><div><font color="#660066"><strong>Event Type </strong></font></div></td><td width="33%" valign="top"><div><font color="#660066"><strong>Time/Location/Day </strong></font></div></td></tr><tr><td width="33%" valign="top" bgcolor="#325c74"><div><font color="#ccff33">MacJonas </font></div></td><td width="33%" valign="top" bgcolor="#325c74"><div><font color="#ccff33">Giveaway </font></div></td><td width="33%" valign="top" bgcolor="#325c74"><div><font color="#ccff33">Unkown </font></div></td></tr><tr><td width="33%" valign="top" bgcolor="#325c74"><div><font color="#ccff33">MacJonas</font></div></td><td width="33%" valign="top" bgcolor="#325c74"><div><font color="#ccff33">Kick Wars CONTEST!</font></div></td><td width="33%" valign="top" bgcolor="#325c74"><div><font color="#ccff33">7 PM Wednesday, MacJonas room!</font></div></td></tr><tr><td width="33%" valign="top" bgcolor="#325c74"><div><font color="#ccff33"> </font></div></td><td width="33%" valign="top" bgcolor="#325c74"><div><font color="#ccff33"> </font></div></td><td width="33%" valign="top" bgcolor="#325c74"><div><font color="#ccff33"> </font></div></td></tr><tr><td width="33%" valign="top" bgcolor="#325c74"><div><font color="#ccff33"> </font></div></td><td width="33%" valign="top" bgcolor="#325c74"><div><font color="#ccff33"> </font></div></td><td width="33%" valign="top" bgcolor="#325c74"><div><font color="#ccff33"> </font></div></td></tr></tbody></table> </span><br /> </p> <p align="left"> </p> </blockquote> </td> </tr></table><table width="629" border="0" cellpadding="0" cellspacing="0"> <tr> <td align="center" valign="middle" scope="col"><div align="left"> <div align="center"> <p>| <a href="http://www.habboboom.co.uk/jobapp.php" target="_blank">Job Applications</a> |</p> </div> </div></td> <td align="center" valign="middle" scope="col"><div align="center"> <p class="navilinks style3"> <a href="http://www.habboboom.co.uk/disclaimer.php" target="_blank">Disclaimer</a></p> </div></td> <td align="center" valign="middle" scope="col"><div align="center"> <p class="navilinks style3">| <a href="/forum/" target="_blank">Forum</a></p> </div></td> <th scope="col"><p> </p> </tr> <tr> <th width="116" scope="col"> </th> <th width="60" scope="col"> </th> <th width="55" scope="col"> </th> <th width="398" scope="col"> </th> </tr></table></body></html></body></html>[/code] Link to comment https://forums.phpfreaks.com/topic/31246-need-help/#findComment-144633 Share on other sites More sharing options...
craygo Posted December 19, 2006 Share Posted December 19, 2006 OK make a table for your events with all the fields you would like in it. I know you only have a couple things showing on the events.php page but you can show just a couple things on the events page then have a link which would send you to a page with all the details.After you make the events table post an sql of the table structure. Make sure you have an auto increment field for each eventRay Link to comment https://forums.phpfreaks.com/topic/31246-need-help/#findComment-144638 Share on other sites More sharing options...
stem Posted December 19, 2006 Author Share Posted December 19, 2006 Ok i made the table in MyphpAdmin and the sql is[code]CREATE TABLE `event` ( `id` int(11) unsigned NOT NULL auto_increment, `host` varchar(50) NOT NULL default '', `event` varchar(50) NOT NULL default '', `place` varchar(25) NOT NULL default '0', PRIMARY KEY (`id`)) ENGINE=MyISAM;[/code]or should it be..[code]CREATE TABLE `event` ( `id` int(11) unsigned NOT NULL auto_increment, `host` varchar(50) NOT NULL auto_increment, `event` varchar(50) NOT NULL auto_increment, `place` varchar(25) NOT NULL auto_increment, PRIMARY KEY (`id`)) ENGINE=MyISAM;[/code] Link to comment https://forums.phpfreaks.com/topic/31246-need-help/#findComment-144643 Share on other sites More sharing options...
craygo Posted December 19, 2006 Share Posted December 19, 2006 The first one Link to comment https://forums.phpfreaks.com/topic/31246-need-help/#findComment-144669 Share on other sites More sharing options...
stem Posted December 19, 2006 Author Share Posted December 19, 2006 ok now i'm guessing i have to link them together somehow? o_Owith a db.php file? which allows me to connect to the database? Link to comment https://forums.phpfreaks.com/topic/31246-need-help/#findComment-144675 Share on other sites More sharing options...
craygo Posted December 19, 2006 Share Posted December 19, 2006 yes you have to connect to the database. I usually use 2 files. just save these in the same folder. That way they can be called upon anytime you want to connect to the database and you do not have to retype your connection stringconfig.php[code]<?php$dbhost = 'localhost'; // database server$dbuser = ''; // db username$dbpass = ''; // db password$dbname = ''; // db name?>[/code]mysql.php[code]<?php$mysql_conn = @mysql_connect($dbhost, $dbuser, $dbpass) or die("Could not connect to Mysql, Please check settings and try again");@mysql_select_db($dbname, $mysql_conn) or die("DataBase does not exist");?>[/code]OK now for the fileslogin.html[code]<form method=POST action="<? $_SERVER['PHP_SELF']?>"><table border=1 cellpadding=3 celspacing=3 align=center width=50%><tr><td colspan=2 align=center>Login</td></tr><input type=hidden name=action value=login><tr><td>Username:</td><td><input type=text name=username size="20"></td><tr><tr><td>Password:</td><td><input type=password name=password size="20"></td><tr><tr><td colspan=2 align=center><input type=submit name=submit value=Login></td><tr></table></form></body></html>[/code]login.php (this is the main page)[code]<?session_start();require('config.php');include('mysql.php');if(isset($_POST['username'])){$username = $_POST['username'];$password = md5($_POST['password']);$getuser = "SELECT * from users WHERE username = '$username' AND password = '$password'"; $result = mysql_query($getuser) or die (mysql_error()); $r = mysql_fetch_array($result); $qualify = mysql_num_rows($result);if($qualify > 0){$_SESSION['username'] = $r['username'];$_SESSION['ugroup'] = $r['type'];?><head><title>Events Login</title><META HTTP-EQUIV="Refresh" content="3;url=eventlist.php"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><link href="elder.css" rel="stylesheet" type="text/css" /></head><body><p align=center>Please wait... you will now be redirected to your server page.</p></body></html><?} else {print '<p align=center>Bad username/password<br>Click <a href="login.php">here</a> to return to login page.';}} else {include('login.html');}?>[/code]elist.php[code]<form name="list" action="changes.php" method="POST"><table width=450 align=center><tr><td width=100>Host</td><td width=150>Event</td><td width=100>Place</td><td width=100>Edit/Delete</td></tr><?php$sql = "SELECT * FROM event";$res = mysql_query($sql) or die (mysql_error());while($r = mysql_fetch_assoc($res)){echo "<tr> <td>".$r['host']."</td> <td>".$r['event']."</td> <td>".$r['place']."</td> <td><input type=checkbox name=ids[] value=".$r['id']."></td> </tr>";}echo "<tr> <td colspan=4 align=center> <input type=submit name=delete value=Delete onclick=\"return confirm('Are you sure you wish to delete the selected item(s)?')\"> <input type=submit name=edit value=Edit></td> </tr> </table> </form>";?>[/code]eventlist.php[code]<?session_start();require('config.php');include('mysql.php');// Check if user is logged inif(isset($_SESSION['username']) && $_SESSION['ugroup'] == 1){$self = $_SERVER['PHP_SELF'];echo "<table width=300 align=center> <tr> <td colspan=2 align=center>Add event here</td> </tr> <form action='changes.php' method=POST> <tr> <td width=100>Host:</td> <td width=200><input type=text name=ehost></td> </tr> <tr> <td width=150>Event:</td> <td width=250><input type=text name=event></td> </tr> <tr> <td width=150>Place:</td> <td width=250><input type=text name=place></td> </tr> <tr> <td colspan=2 align=center><input type=submit name=add value=\"Add Event\"></td> </tr> </form> </table><hr>";include("elist.php");} else {print '<p align=center>NO SOUP FOR YOU!!! Please login <a href="login.php">HERE</a></p>';}?></html>[/code]changes.php[code]<?phpsession_start(); // Sql connection hererequire('config.php');include('mysql.php');if(isset($_SESSION['username']) && $_SESSION['ugroup'] == 1){$self = $_SERVER['PHP_SELF'];if(isset($_POST['update'])){echo "<p align=center>";// Connect to mysqlforeach($_POST['eventid'] as $val){$id = $_POST['eventid'][$val];$host = $_POST['host'][$val];$event = $_POST['event'][$val];$place = $_POST['place'][$val];$sql = "UPDATE event SET host = '".$host."', event = '".$event."', place = '".$place."' WHERE id = '".$val."'";$res = mysql_query($sql); if(!$res){ echo "Could not update event# $id<br>SQL: $sql<br> Error: ".mysql_error(); } else { echo "Event# $id Sucessfully updated<br>"; }}echo "Click <a href=\"eventlist.php\">HERE</a> To return to event list</p>";} else { if(isset($_POST['delete'])){ echo "<p align=center>"; // Start array of id's $ids = array(); // Fill array with values foreach($_POST['ids'] as $id){ $ids[] = $id; } // Loop through array and delete each id foreach($ids as $eventid){ $sql = "DELETE FROM event WHERE id = $eventid"; $res = mysql_query($sql) or die (mysql_error()); if(!$res){ echo "Could not DELETE event# $eventid<br>SQL: $sql<br> Error: ".mysql_error(); } else { echo "Event# $eventid Sucessfully deleted<br>"; } } echo "Click <a href=\"eventlist.php\">HERE</a> To return to Event list</p>"; } else { if(isset($_POST['add'])){ echo "<p align=center>"; $sql = "INSERT INTO event SET host = '".$_POST['ehost']."', event = '".$_POST['event']."', place = '".$_POST['place']."'"; $res = mysql_query($sql); if(!$res){ echo "Could not add new event<br>SQL: $sql<br> Error: ".mysql_error()."<br> Click <a href=\"eventlist.php\">HERE</a> To return to Event list</p>"; } else { echo "New Event added<br> Click <a href=\"eventlist.php\">HERE</a> To return to Event list</p>"; } } else {// start your array of id's$ids = array();// fill your array with the id's selected foreach($_POST['ids'] as $id){ $ids[] = $id; }// start your formecho "<form name=edit action=\"$self\" method=POST>";// Loop through the id's. query database to get infor for each id foreach($ids as $eventid){ $sql = "SELECT * FROM event WHERE id = $eventid"; $res = mysql_query($sql) or die (mysql_error()); $i=0; $r = mysql_fetch_array($res);// print the form for each id echo "<table width=500 align=center>"; echo "<tr><td colspan=2 align=center><font color=red size=4><b>Now editing EVENT# ".$r['id']."</b></font></td></tr>"; while($i < mysql_num_fields($res)){ $meta = mysql_fetch_field($res, $i); /***************** If you would like to modify the stock number, remove **** && $meta->name <> "stock" **** below ******************/ if($meta->name <> "id"){ echo "<input type=hidden name=eventid[".$r['id']."] value=\"".$r['id']."\">"; print '<tr> <td width=150>'.$meta->name.'</td> <td width=350><input type=text size=50 name="'.$meta->name.'['.$r['id'].']" value="'.$r[$i].'"></td> </tr>'; } $i++; } echo "<hr>"; } print '<tr> <td colspan=2 align=center><input type=submit name=update value=Change></td> </tr> </table> </form>'; } }}} else {print '<p align=center>NO SOUP FOR YOU!!! Please login <a href="login.php">HERE</a></p>';}?>[/code]Now just put all these files in the same directory. I will post the code for your main page in a minute.Ray Link to comment https://forums.phpfreaks.com/topic/31246-need-help/#findComment-144702 Share on other sites More sharing options...
stem Posted December 19, 2006 Author Share Posted December 19, 2006 ok :DThanks so much for your help too :) Link to comment https://forums.phpfreaks.com/topic/31246-need-help/#findComment-144707 Share on other sites More sharing options...
craygo Posted December 19, 2006 Share Posted December 19, 2006 here is the updated events.php[code]<html><head><title>HabboBoom ~ Events</title></head><!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"><meta name="Description" content="HabboBoom is a ever exspanding Habbo Hotel Uk Unoffical fansite which is hoping to become Offical in the near further" /><meta name="Keywords" content="HabHabbo HotelHabboHabbo FansitesHabbo sitesHabbo Community<br />HabboBoom<br />HB<br />Habbo Radio<br />Habbo Boom" /><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><style>a.navilinks:link {text-decoration:none;font-weight:bold;}a.navilinks:link {text-decoration:none;font-weight:bold;}a.navilinks:link {text-decoration:none;font-weight:bold;}a.navilinks:hover {text-decoration:none;font-weight:bold;}body,td,th { font-family: Verdana; font-size: 10px; color: #CCCCCC;}body { background-image: url(background.PNG);}.option{cursor:pointer;color:#000000;text-decoration:none;}a:link { color: #00CCFF; text-decoration: none;}a:visited { color: #00CCFF; text-decoration: none;}a:hover { color: #006699; text-decoration: underline;}a:active { color: #00CCFF; text-decoration: none;}a { font-weight: bold;#Layer1 { position:absolute; width:300px; height:300px; z-index:5;}#Layer1 { position:absolute; width:75; height:86; z-index:5; left: 904px; top: 7px;}.style3 {font-size: 9px; }.style4 {font-size: 9px; font-family: Verdana, Arial, Helvetica, sans-serif; }.style6 {font-family: Verdana, Arial, Helvetica, sans-serif; }</style></head><body><center><p> </p><p> </p><p><br /> <br /></p><table width="629" height="29" border="0" cellspacing="0"> <tr> <td height="29" background="/images/Images/MB/top.gif"> </td> </tr> <tr> <td background="/images/Images/MB/middle.gif"><blockquote><b>Dear Habbo, <blockquote></b> <p align="left"><div><img width="246" height="21" src="/events_logo.gif" alt="" title=""> <font size="1"><br><br><font face="Verdana">Welcome to the Events area of HabboBOOM!</font></font></div><div><font size="1"><font face="Verdana">We have taken the time to plan events, for all you lovely habbos!</font></font></div><div><font size="1"><font face="Verdana">Below are the planned events!! </font></font></div><br><br><br><img style="margin: 0px;" width="49" height="96" align="right" src="/tele_ani.gif" alt="" title=""><br><table style="border-collapse: collapse;" width="436" cellspacing="0" cellpadding="3" bordercolor="#000000" border="0" bgcolor="#79cdcd"><tbody> <tr> <td width="33%" valign="top"><div><font color="#660066"><strong>Event Host </strong></font></div></td> <td width="33%" valign="top"><div><font color="#660066"><strong>Event Type </strong></font></div></td> <td width="33%" valign="top"><div><font color="#660066"><strong>Time/Location/Day </strong></font></div></td> </tr><?phprequire('../config.php');include('../includes/mysql.php');$sql = "SELECT * FROM event";$res = mysql_query($sql) or die (mysql_error());while($r = mysql_fetch_assoc($res)){ echo ' <tr> <td width="33%" valign="top" bgcolor="#325c74"><div><font color="#ccff33">'.$r['host'].' </font></div></td> <td width="33%" valign="top" bgcolor="#325c74"><div><font color="#ccff33">'.$r['event'].' </font></div></td> <td width="33%" valign="top" bgcolor="#325c74"><div><font color="#ccff33">'.$r['place'].'</font></div></td> </tr>';}?></tbody></table></span><br /> </p> <p align="left"> </p> </blockquote> </td> </tr></table><table width="629" border="0" cellpadding="0" cellspacing="0"> <tr> <td align="center" valign="middle" scope="col"><div align="left"> <div align="center"> <p>| <a href="http://www.habboboom.co.uk/jobapp.php" target="_blank">Job Applications</a> |</p> </div> </div></td> <td align="center" valign="middle" scope="col"><div align="center"> <p class="navilinks style3"> <a href="http://www.habboboom.co.uk/disclaimer.php" target="_blank">Disclaimer</a></p> </div></td> <td align="center" valign="middle" scope="col"><div align="center"> <p class="navilinks style3">| <a href="/forum/" target="_blank">Forum</a></p> </div></td> <td align="center" valign="middle" scope="col"><div align="center"> <p class="navilinks style3">| <a href="login.php">Log into admin</a></p> </div></td> <th scope="col"><p> </p> </tr> <tr> <th width="116" scope="col"> </th> <th width="60" scope="col"> </th> <th width="55" scope="col"> </th> <th width="398" scope="col"> </th> </tr></table></body></html>[/code]Ray Link to comment https://forums.phpfreaks.com/topic/31246-need-help/#findComment-144713 Share on other sites More sharing options...
stem Posted December 19, 2006 Author Share Posted December 19, 2006 Thank you so much Rayi couldn't of done this without your help :D Link to comment https://forums.phpfreaks.com/topic/31246-need-help/#findComment-144716 Share on other sites More sharing options...
craygo Posted December 19, 2006 Share Posted December 19, 2006 Now you have to study it and learn!!! ;Dthat's how I learned.ray Link to comment https://forums.phpfreaks.com/topic/31246-need-help/#findComment-144721 Share on other sites More sharing options...
stem Posted December 19, 2006 Author Share Posted December 19, 2006 I am studying it =Dand i found a few mistakes :p!i've sorted most of them out just the login.php and the install.phpthey both need to be validated somehow? because atm their action is just action=""and i can't login it just keeps comming up bad password :o!and ideas? :p Link to comment https://forums.phpfreaks.com/topic/31246-need-help/#findComment-144770 Share on other sites More sharing options...
craygo Posted December 19, 2006 Share Posted December 19, 2006 Here is the install.php[code]<?phpif(isset($_POST['submit'])){// Sql connection hererequire('config.php');include('mysql.php');$password = md5($_POST['password']);$sql = "INSERT INTO users SET username = '".$_POST['username']."', password = '".$password."', ugroup = '".$_POST['ugroup']."'";$res = mysql_query($sql);if(!$res){echo "<b>could not insert new user!!</b><br>Error: ".mysql_error()."<br>SQL: ".$sql."<br>Click <a href=\"install.php\">HERE</a> to return to insert page";} else {echo "New user entered into database<br>Click <a href=\"install.php\">HERE</a> to return to insert page";}} else {?><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Sign up</title></head><body><form id="form1" name="form1" method="post" action="<?=$_SERVER['PHP_SELF']?>"> <table width="143" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <th scope="col">Username:</th> </tr> <tr> <td><label> <input type="text" name="username" id="username" /> </label></td> </tr> <tr> <th>Password:</th> </tr> <tr> <td><label> <input type="password" name="password" id="password" /> </label></td> </tr> <tr> <th>Group:</th> </tr> <tr> <td><label> <div align="center"> <select name="ugroup"> <option value="1">Admin</option> <option value="2">Staff</option> <option value="3" selected="selected">Trainee</option> </select> </div> </label> </td> </tr> <tr> <td align=center><br><label> <input type="submit" name="submit" value="Submit" id="password" /> </label></td> </tr> </table></form><?php}?></body></html>[/code]Ray Link to comment https://forums.phpfreaks.com/topic/31246-need-help/#findComment-144782 Share on other sites More sharing options...
stem Posted December 20, 2006 Author Share Posted December 20, 2006 Your going to probably hate me for this...but i can install fine... login fine... just when it redirects me to the events page it says click here to login! :(any idea why? i've looked and i think it has something to do with the session? o_Oi looked around and i found something like:[Code]<?php// *** Validate request to login to this site.if (!isset($_SESSION)) { session_start();}$loginFormAction = $_SERVER['PHP_SELF'];if (isset($_GET['accesscheck'])) { $_SESSION['PrevUrl'] = $_GET['accesscheck'];}[/Code]Will that need to be in my events bit? it looks like it's saying the session is from the previous URL? or am i wrong? :pif you don't understand whats wrong visit these links :phttp://www.habboboom.co.uk/community/staff/login.phpUsername => benpassword => 123----------------------and may i ask where is the best place to Learn Php? :oi'm taking a college course on computer programming... but we don't start php till next year i think... if we start it at all! :( Link to comment https://forums.phpfreaks.com/topic/31246-need-help/#findComment-145140 Share on other sites More sharing options...
craygo Posted December 20, 2006 Share Posted December 20, 2006 What group did you put that user in. I only have it setup for the admin which you made "1" if it is any other group you will get the error.Ray Link to comment https://forums.phpfreaks.com/topic/31246-need-help/#findComment-145274 Share on other sites More sharing options...
stem Posted December 20, 2006 Author Share Posted December 20, 2006 i made an account with each group and non worked if you click the link above...and log in usingusername: benpassword: 123you'll see it just redirects you. Link to comment https://forums.phpfreaks.com/topic/31246-need-help/#findComment-145428 Share on other sites More sharing options...
craygo Posted December 20, 2006 Share Posted December 20, 2006 is the user ben in group 1?? Link to comment https://forums.phpfreaks.com/topic/31246-need-help/#findComment-145435 Share on other sites More sharing options...
stem Posted December 20, 2006 Author Share Posted December 20, 2006 Ray!! omg i found the problem!!hahaon the Eventslist.phpyou had[Code]if(isset($_SESSION['username']) && $_SESSION['ugroup'] == 1){[/Code]i remember seeing something so i changed it and it works it should of been[code]if(isset($_SESSION['username']) && $_SESSION['ugroup'] = 1){[/code]only 1 = sign :P Link to comment https://forums.phpfreaks.com/topic/31246-need-help/#findComment-145446 Share on other sites More sharing options...
craygo Posted December 21, 2006 Share Posted December 21, 2006 It should be 2 = signs. If you have one that means it is just not going to check the ugroup. I think the problem may be the assignment of the ugroup. Back on the login.php page you assign the session value to the ugroup with a field from the table. Is the field correct?? I have it as[code]$_SESSION['ugroup'] = $r['type'];[/code]Is your group field called type?? if not change that line with the field name. or whatever field holds the group.Ray Link to comment https://forums.phpfreaks.com/topic/31246-need-help/#findComment-145830 Share on other sites More sharing options...
stem Posted December 21, 2006 Author Share Posted December 21, 2006 ok on login.php i have[code]$_SESSION['username'] = $r['username'];$_SESSION['ugroup'] = $r['type'];[/code]and on install.phpwhere you select the rank i have;[Code] <div align="center"> <select name="ugroup"> <option value="1">Admin</option> <option value="2">Staff</option> <option value="3" selected="selected">Trainee</option> </select>[/code] Link to comment https://forums.phpfreaks.com/topic/31246-need-help/#findComment-145834 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.