Jump to content

andrew_biggart

Members
  • Posts

    363
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by andrew_biggart

  1. Sorry i dont really understand at all im an absolute beginner to this sorry! I understand the get function ok but i dont understand how i would go about implementing it! Thankyou btw
  2. Ok so i have been given an assignment to do for uni but i really dont have a clue what im doing! Just after some advice and help please. I have to built a "simple" guestbook or forum. I have been given a few files which i will post below! What i would like to know is there a simple way to add all of the elements to one page instead of four different pages. I.e read posts, write delete etc all running from the same page. I can get it working on seperate pages but i want to try and run it off the one page and then build up from there! Any help would be appreciateded and thanks for reading! Ok now for the files! Bare with me if you can! readposts.php <?php //Set no caching header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>My Guestbook</title> <script type="text/javascript" src="js/mootools.js"></script> <script type="text/javascript" src="js/read.php"></script> </head> <body> <div> <h1>Read My Guestbook</h1> <div id="commentList"> </div> </div> </body> </html> insertpost.php <?php //Set no caching header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>My Guestbook</title> <script type="text/javascript" src="js/mootools.js"></script> <script type="text/javascript" src="js/insert.php"></script> </head> <body> <div> <h1>Insert Post into Guestbook</h1> <form id="newComment" action="#"> <div><label>Name: </label> <input type="text" name="name"/> </div> <div><label>Comment: </label> <textarea name="comment"></textarea> </div> <div><input type="submit" value="submit"/></div> </form> </div> </body> </html> editpost.php <?php //Set no caching header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>My Guestbook</title> <script type="text/javascript" src="js/mootools.js"></script> <script type="text/javascript" src="js/edit.php"></script> </head> <body> <div> <h1>Edit Post in Guestbook</h1> <form id="newComment" action="#"> <div><label>ID: </label> <input type="text" name="id"/> </div> <div><label>Name: </label> <input type="text" name="name"/> </div> <div><label>Comment: </label> <textarea name="comment"></textarea> </div> <div><input type="submit" value="submit"/></div> </form> </div> </body> </html> deletepost.php <?php //Set no caching header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>My Guestbook</title> <script type="text/javascript" src="js/mootools.js"></script> <script type="text/javascript" src="js/delete.php"></script> </head> <body> <div> <h1>Delete Post in Guestbook</h1> <form id="newComment" action="#"> <div><label>ID: </label> <input type="text" name="id"/> </div> <div><input type="submit" value="submit"/></div> </form> </div> </body> </html> control.php <?php require_once 'php/class.GuestBook.php'; $guestbook = new GuestBook('parkinson_guestbook'); function insertPost() { global $guestbook; return $guestbook->insert($_POST); } function editPost() { global $guestbook; return $guestbook->update($_POST); } function getSinglePost(){ global $guestbook; return $guestbook->getPost($_GET['id']); } function getPage() { global $guestbook; return $guestbook->getPostList(); } function removePost(){ global $guestbook; return $guestbook->removePost($_GET['id']); } echo $_GET['action'](); classdatabase.php <?php # Name: Database.class.php # File Description: MySQL Class to allow easy and clean access to common mysql commands # Author: ricocheting # Web: http://www.ricocheting.com/scripts/ # Update: 2/2/2009 # Version: 2.1 # Copyright 2003 ricocheting.com /* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ //require("config.php"); //$db = new Database($config['server'],$config['user'],$config['pass'],$config['database'],$config['tablePrefix']); ################################################################################################### ################################################################################################### ################################################################################################### class Database { var $server = ""; //database server var $user = ""; //database login name var $pass = ""; //database login password var $database = ""; //database name var $pre = ""; //table prefix ####################### //internal info var $record = array(); var $error = ""; var $errno = 0; //table name affected by SQL query var $field_table= ""; //number of rows affected by SQL query var $affected_rows = 0; var $link_id = 0; var $query_id = 0; #-############################################# # desc: constructor function Database($server, $user, $pass, $database, $pre=''){ $this->server=$server; $this->user=$user; $this->pass=$pass; $this->database=$database; $this->pre=$pre; }#-#constructor() #-############################################# # desc: connect and select database using vars above # Param: $new_link can force connect() to open a new link, even if mysql_connect() was called before with the same parameters function connect($new_link=false) { $this->link_id=@mysql_connect($this->server,$this->user,$this->pass,$new_link); if (!$this->link_id) {//open failed $this->oops("Could not connect to server: <b>$this->server</b>."); } if(!@mysql_select_db($this->database, $this->link_id)) {//no database $this->oops("Could not open database: <b>$this->database</b>."); } // unset the data so it can't be dumped $this->server=''; $this->user=''; $this->pass=''; $this->database=''; }#-#connect() #-############################################# # desc: close the connection function close() { if(!mysql_close($this->link_id)){ $this->oops("Connection close failed."); } }#-#close() #-############################################# # Desc: escapes characters to be mysql ready # Param: string # returns: string function escape($string) { if(get_magic_quotes_gpc()) $string = stripslashes($string); return mysql_real_escape_string($string); }#-#escape() #-############################################# # Desc: executes SQL query to an open connection # Param: (MySQL query) to execute # returns: (query_id) for fetching results etc function query($sql) { // do query $this->query_id = @mysql_query($sql, $this->link_id); if (!$this->query_id) { $this->oops("<b>MySQL Query fail:</b> $sql"); } $this->affected_rows = @mysql_affected_rows(); return $this->query_id; }#-#query() #-############################################# # desc: fetches and returns results one line at a time # param: query_id for mysql run. if none specified, last used # return: (array) fetched record(s) function fetch_array($query_id=-1) { // retrieve row if ($query_id!=-1) { $this->query_id=$query_id; } if (isset($this->query_id)) { $this->record = @mysql_fetch_assoc($this->query_id); }else{ $this->oops("Invalid query_id: <b>$this->query_id</b>. Records could not be fetched."); } // unescape records if($this->record){ $this->record=array_map("stripslashes", $this->record); //foreach($this->record as $key=>$val) { // $this->record[$key]=stripslashes($val); //} } return $this->record; }#-#fetch_array() #-############################################# # desc: returns all the results (not one row) # param: (MySQL query) the query to run on server # returns: assoc array of ALL fetched results function fetch_all_array($sql) { $query_id = $this->query($sql); $out = array(); while ($row = $this->fetch_array($query_id, $sql)){ $out[] = $row; } $this->free_result($query_id); return $out; }#-#fetch_all_array() #-############################################# # desc: frees the resultset # param: query_id for mysql run. if none specified, last used function free_result($query_id=-1) { if ($query_id!=-1) { $this->query_id=$query_id; } if(!@mysql_free_result($this->query_id)) { $this->oops("Result ID: <b>$this->query_id</b> could not be freed."); } }#-#free_result() #-############################################# # desc: does a query, fetches the first row only, frees resultset # param: (MySQL query) the query to run on server # returns: array of fetched results function query_first($query_string) { $query_id = $this->query($query_string); $out = $this->fetch_array($query_id); $this->free_result($query_id); return $out; }#-#query_first() #-############################################# # desc: does an update query with an array # param: table (no prefix), assoc array with data (doesn't need escaped), where condition # returns: (query_id) for fetching results etc function query_update($table, $data, $where='1') { $q="UPDATE `".$this->pre.$table."` SET "; foreach($data as $key=>$val) { if(strtolower($val)=='null') $q.= "`$key` = NULL, "; elseif(strtolower($val)=='now()') $q.= "`$key` = NOW(), "; else $q.= "`$key`='".$this->escape($val)."', "; } $q = rtrim($q, ', ') . ' WHERE '.$where.';'; return $this->query($q); }#-#query_update() #-############################################# # desc: does an insert query with an array # param: table (no prefix), assoc array with data # returns: id of inserted record, false if error function query_insert($table, $data) { $q="INSERT INTO `".$this->pre.$table."` "; $v=''; $n=''; foreach($data as $key=>$val) { $n.="`$key`, "; if(strtolower($val)=='null') $v.="NULL, "; elseif(strtolower($val)=='now()') $v.="NOW(), "; else $v.= "'".$this->escape($val)."', "; } $q .= "(". rtrim($n, ', ') .") VALUES (". rtrim($v, ', ') .");"; if($this->query($q)){ //$this->free_result(); return mysql_insert_id(); } else return false; }#-#query_insert() #-############################################# # desc: throw an error message # param: [optional] any custom error to display function oops($msg='') { if($this->link_id>0){ $this->error=mysql_error($this->link_id); $this->errno=mysql_errno($this->link_id); } else{ $this->error=mysql_error(); $this->errno=mysql_errno(); } ?> <table align="center" border="1" cellspacing="0" style="background:white;color:black;width:80%;"> <tr><th colspan=2>Database Error</th></tr> <tr><td align="right" valign="top">Message:</td><td><?php echo $msg; ?></td></tr> <?php if(strlen($this->error)>0) echo '<tr><td align="right" valign="top" nowrap>MySQL Error:</td><td>'.$this->error.'</td></tr>'; ?> <tr><td align="right">Date:</td><td><?php echo date("l, F j, Y \a\\t g:i:s A"); ?></td></tr> <tr><td align="right">Script:</td><td><a href="<?php echo @$_SERVER['REQUEST_URI']; ?>"><?php echo @$_SERVER['REQUEST_URI']; ?></a></td></tr> <?php if(strlen(@$_SERVER['HTTP_REFERER'])>0) echo '<tr><td align="right">Referer:</td><td><a href="'.@$_SERVER['HTTP_REFERER'].'">'.@$_SERVER['HTTP_REFERER'].'</a></td></tr>'; ?> </table> <?php }#-#oops() }//CLASS Database ################################################################################################### classGuestbook.php <?php require_once 'class.Database.php'; class GuestBook { //Edit these to connect to a different database var $db_server = 'mysqlb14.webcontrolcenter.com'; var $db_user = 'agile'; var $db_pass = 'adila'; var $db_name = 'agile'; //Primary key field is assumed to be called id. Edit if it's not var $id = 'id'; //Field to order posts by, could be set to a date field var $orderBy = ''; var $db, $table, $order; /** * Constructor initialises the database class and the table * which the guest book uses. * @param $table String */ function __construct($table, $primaryKey = '',$order = 'DESC'){ $this->db = new Database($this->db_server, $this->db_user, $this->db_pass, $this->db_name); $this->db->connect(); $this->table = $table; if($primaryKey != '') $this->id = $primaryKey; if($this->orderBy == '') $this->orderBy = $this->id; $this->order = $order; } /** * Inserts an array into a table where the keys are the * column names. Returns the ID of the row just inserted. * @return Number * @param $array String */ function insert($array){ return $this->db->query_insert($this->table, $array); } /** * Updates an existing record. * @return Number * @param $array Array * @param $where Number */ function update($array){ return $this->db->query_update($this->table, $array, $this->id .'='.$array[$this->id]); } /** * Returns a single record from the table. * @return JSON Object * @param $id Number */ function getPost($id){ $sql = 'SELECT * FROM `'.$this->table.'` WHERE '.$this->id.' = '.$id; $result = $this->db->query_first($sql); return json_encode($result); } /** * Returns an array of posts, if no parameters are specified, it will * return the 10 most recently posted. * @return JSON Array * @param $size Object[optional] * @param $offset Object[optional] */ function getPostList($size = 10, $offset = 0){ $sql = 'SELECT * FROM `'.$this->table.'` ORDER BY '.$this->orderBy.' '.$this->order.' LIMIT '.$offset.', '.$size; //$sql = 'SELECT * FROM `'.$this->table.'`'; $result = $this->db->fetch_all_array($sql); return json_encode($result); } function removePost($id) { $sql = 'DELETE FROM `'.$this->table.'` WHERE '.$this->id.' = '.$id; return $this->db->query($sql); } } javascript files.......... read.php <?php //Set no caching header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); ?> var guestbook; window.addEvent('domready', function(){ guestbook = new GuestBook(); }); var GuestBook = new Class({ initialize: function(){ var req = new Request.JSON({ url: 'control.php?action=getPage', onSuccess: this.success }).send(); }, success: function(jArray){ jArray.each(function(post){ var post = new PostItem(post.id, post.name, post.comment); post.display().inject($('commentList')); }, this); } }); var PostItem = new Class({ initialize: function(id, name, comment){ this.id = id; this.name = name; this.comment = comment; }, display: function(){ var cont = new Element('div',{ 'class':'postItem', 'id':'post'+this.id }); var title = new Element('h3',{ 'class':'postTitle', 'text':this.name + ' says...' }); var comment = new Element('p',{ 'class':'postComment', 'text':this.comment }); title.inject(cont); comment.inject(cont); return cont; } }); insert.php <?php //Set no caching header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); ?> window.addEvent('domready',domReady); function domReady(){ var guestbook = new GuestBook(); } GuestBook = new Class({ initialize: function(){ $('newComment').addEvent('submit', this.addComment); }, addComment: function(e){ e.preventDefault(); var req = new Request({ url:'control.php?action=insertPost', onSuccess:commentAddSuccess }).post(this); function commentAddSuccess(idNo){ new Element('span',{ 'text':'inserted item ' + idNo }).inject($('newComment')); } }, }); edit.php <?php //Set no caching header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); ?> window.addEvent('domready',domReady); function domReady(){ var guestbook = new GuestBook(); } GuestBook = new Class({ initialize: function(){ $('newComment').addEvent('submit', this.addComment); }, addComment: function(e){ e.preventDefault(); var req = new Request({ url:'control.php?action=editPost', onSuccess:commentAddSuccess }).post(this); function commentAddSuccess(){ new Element('span',{ 'text':'edited item ' }).inject($('newComment')); } }, }); delete.php <?php //Set no caching header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); ?> window.addEvent('domready',domReady); function domReady(){ var guestbook = new GuestBook(); } GuestBook = new Class({ initialize: function(){ $('newComment').addEvent('submit', this.addComment); }, addComment: function(e){ e.preventDefault(); var req = new Request({ url:'control.php?action=removePost&id=' + this.id.value, onSuccess:commentAddSuccess }).send(); function commentAddSuccess(){ new Element('span',{ 'text':'deleted item' }).inject($('newComment')); } }, });
  3. Its weird because it works perfectly when i directly put the php code directly into the div! but when i try to add it via a php include page it doesnt!
  4. Im not really sure to be honest but i removed it and then the login form disappear!! im assuming it was behind the flash banner!
  5. ok il give you the code and see what u can spot! Required file! <?php $username=$_SESSION['myusername']; if(isset($_SESSION['myusername'])) { echo " <img alt='' src='../icons/myacc.gif' width='12' height='11' /> <a class='button6' href='my_profile.php'>My Account</a> <img alt='' src='../icons/mypro.gif' width='12' height='11' /> <a class='button6' href='profile.php?username=$username'>My Profile</a> <img alt='' src='../icons/mymes.gif' width='12' height='11' /> <a class='button6' href='my_profile_messages.php'>My Messages</a> <img alt='' src='../icons/myale.gif' width='11' height='11' /> <a class='button6' href='my_profile_alerts.php'>My Alerts</a> <img alt='' src='../icons/myreq.gif' width='12' height='11' /> <a class='button6' href='my_profile_requests.php'>My Requests</a> <img alt='' src='../icons/myfri.gif' width='12' height='11' /> <a class='button6' href='my_profile_friends.php'>My Friends</a> <img alt='' src='../icons/mylog.gif' width='12' height='12' /> <a class='button6' href='logout.php'>Logout</a> "; } else{ echo " <form method='post' action='check_login.php'> <table style='float: right'> <tr> <td><img alt='' src='../Header_images/login.jpg' width='120' height='18' /></td> <td><input class='username' name='myusername' type='text' value='Username'/></td> <td class='logmein'>:Username</td> <td><input class='password' name='mypassword' type='password' value='Password'/></td> <td class='logmein'>:Password</td> <td><input class='submit' name='Submit2' type='submit' value='Cumon in'/><a href='user_register.htm'><input class='register' name='Submit2' type='button' value='Register'/></a></td> </tr> </table> </form> "; } ?> and this is being injected hear! <div id="nav_menu"> <?php require_once("../Includes/navmenu.php"); ?> </div> and the css im using for the div is #nav_menu { width:640px; height:25px; background-image:url('../Layout_images/menu_new.gif'); background-repeat:no-repeat; padding-left:188px; padding-right:60px; padding-top:5px; text-align:right; } I have been able to include my flash banner and footer successfully i jut cant get this php to work properly! it adds it to the page but 30-40px below where it should be! im not able to use the login form! and it moves the flash banner down with it! How ever when i remove the nav code and keep the flash banner require there the banner is in the correct place! Thanks
  6. Im still having some trouble with this! it is injecting the correct php but its not appearing inside the div proberly where it should be its slightly below it! any ideas?
  7. ok i have got it working now thanks! i already had the session start at the top the problem was infact the path to the include file! Thanks guys
  8. Ok ive been trying to get this to work for days! But is it possible to have this code on a seperate page and use an include on every page you want it in? <?php $username=$_SESSION['myusername']; if(isset($_SESSION['myusername'])) { echo " <img alt='' src='../icons/myacc.gif' width='12' height='11' /> <a class='button6' href='my_profile.php'>My Account</a> <img alt='' src='../icons/mypro.gif' width='12' height='11' /> <a class='button6' href='profile.php?username=$username'>My Profile</a> <img alt='' src='../icons/mymes.gif' width='12' height='11' /> <a class='button6' href='my_profile_messages.php'>My Messages</a> <img alt='' src='../icons/myale.gif' width='11' height='11' /> <a class='button6' href='my_profile_alerts.php'>My Alerts</a> <img alt='' src='../icons/myreq.gif' width='12' height='11' /> <a class='button6' href='my_profile_requests.php'>My Requests</a> <img alt='' src='../icons/myfri.gif' width='12' height='11' /> <a class='button6' href='my_profile_friends.php'>My Friends</a> <img alt='' src='../icons/mylog.gif' width='12' height='12' /> <a class='button6' href='logout.php'>Logout</a> "; } else{ echo " <form method='post' action='check_login.php'> <table style='float: right'> <tr> <td><img alt='' src='../Header_images/login.jpg' width='120' height='18' /></td> <td><input class='username' name='myusername' type='text' value='Username'/></td> <td class='logmein'>:Username</td> <td><input class='password' name='mypassword' type='password' value='Password'/></td> <td class='logmein'>:Password</td> <td><input class='submit' name='Submit2' type='submit' value='Cumon in'/><a href='user_register.htm'><input class='register' name='Submit2' type='button' value='Register'/></a></td> </tr> </table> </form> "; } ?> So thats the code i want to have on the include page! called navmenu.php and ive been trying this code to try and include it on my test page but its not working. <?php include("navmenu.php"); ?> I am doing something wrong? Thanks in advance
  9. Ok im having a little trouble creating a send forgotten password page! its doing my head in to be frank! i found a good example, copied it and got it working. Now im trying to intigrate it into my page but it wont work. This is the example form. <table width="380" border="0" cellpadding="3" cellspacing="1" > <tr> <td width="33%"><strong>Enter your email : </strong></td> <td width="67%"><form name="form1" method="post" action="send_password_ac.php"> <input name="email_to" type="text" id="mail_to" size="25">USERNAME: <input name="username" type="text" id="username" size="25"> <input type="submit" name="Submit" value="Submit"> </form> </td> </tr> </table> This is the php page, which works with the example but doesnt send the password with my form. <? include("config_members.php"); // value sent from form $email_to=$_POST['email_to']; $username=$_POST['username']; // table name // value sent from form $email_to=$_POST['email_to']; // table name $tbl_name=User_infoT; // retrieve password from table where e-mail = $email_to(mark@phpeasystep.com) $sql="SELECT Password FROM $tbl_name WHERE Email='$email_to' AND Username='$username'"; $result=mysql_query($sql); // if found this e-mail address, row must be 1 row // keep value in variable name "$count" $count=mysql_num_rows($result); // compare if $count =1 row if($count==1){ $rows=mysql_fetch_array($result); // keep password in $your_password $your_password=$rows['password']; // ---------------- SEND MAIL FORM ---------------- // send e-mail to ... $to=$email_to; // Your subject $subject="www.weloveweed.co.uk | Your password !"; // From $header="AdMiN <support@weloveweed.co.uk>"; // Your message $header="from: AdMiN <support@weloveweed.co.uk>\r\n"; $messages= "You forgot your fucking pssword you twat. Dont let this happen to offer or I will start to get extremly fucked off! \r\n"; $messages.="Your password is $your_password, so remember it this time. \r\n"; $messages.="If you continue to have problems then please use the contact us section of weloveweed to report the problem and any error you are receiving. \r\n"; $messages.="Luff AdMiN \r\n"; $messages .= "******************************This Is An Automatically Generated Message, Do Not Repond!"; // send email $sentmail = mail($to,$subject,$messages,$header); } // else if $count not equal 1 else { echo "<h1 class=comment_status2>You are not a registered member, please register to continue.</h1>"; } // if your email succesfully sent if($sentmail){ echo "<h1 class=comment_status1>Your Password Has Been Sent To Your Email Address.</h1>"; } else { echo "<h1 class=comment_status2>Cannot send password to your e-mail address.</h1>"; } ?> And hear is my form which doesnt seem to work for some reason even know its the same! <form method="form1" action="send_password_ac.php"> <table class="style3"> <tr><td colspan="2" class="style4"><strong>Forgot your password? Don&#39;t worry!</strong></td></tr> <tr> <td class="myprofile_subtext">Your email address :</td> <td><input name="email_to" id="mail_to" maxlength="100" type="text" /></td> </tr> <tr> <td class="myprofile_subtext">Username :</td> <td><input name="username" id="username" maxlength="8" type="text" value="" /></td> </tr> <tr> <td colspan="2" class="style5"><input class="login23" name="submit" type="submit" value="Email password" /></td> </tr> </table> </form> can anyone help?
  10. Very simple question but how do you write a WHERE statement for Where Email='$email_to' and Username='$username' ??? im just not sure about the and bit!
  11. Ok ive got my head around it now and it is working with that code! thankyou very much premiso!
  12. Ok so now its just echoing the blog full status even when i only have 2 entries in my blog!! <?php include("config_contact.php"); $username=$_SESSION['myusername']; // Retrieve data from database $sql = "SELECT count(Blog_username) as blogcount FROM User_blogT WHERE Blog_username='$username' "; $result = mysql_query($sql); if($row['blogcount'] = 3) { echo "You are only allowed to Have 3 entries to your blog at any one time. If you would like to update your blog please delete one of the older entries."; } else{ echo" <form method='post' action='my_profile_blog_submit.php'> <table class='myprofile_blog'> <tr><td class='myprofile_subtext'>Subject :</td><td class='myprofile_blogsub'> <input name='Blog_subject' type='text' style='width: 413px' /></td></tr> <tr><td class='myprofile_subtext' style='width: 120px' valign='top'>Message :</td><td> <textarea name='Blog_message' style='width: 505px; height: 152px'></textarea></td></tr> </table> <br /> <br /> <br /> <table> <tr><td class='myprofile_changesh'>Add a new entry to your Blog ...</td><td class='myprofile_changesh'> </td></tr> <tr><td class='myprofile_subsub'>Add another entry to your blog. Please delete the older entries that are outdated and try and get it to a limit of 3 or 4 entries.</td></tr> <tr><td colspan='2'></td></tr> </table> <br /> <table class='myprofile_change'> <tr><td><input class='submit_blog' name='addblog' type='submit' value='Post that shit' /></td></tr> </table> </form> "; } ?>
  13. This is the most recent code i am using btw! <?php include("config_contact.php"); $username=$_SESSION['myusername']; // Retrieve data from database $sql = "SELECT count(Blog_username) as blogcount FROM User_blogT WHERE Blog_username='$username' "; $result = mysql_query($sql); if($row['blogcount'] > 3){ echo "You are only allowed to Have 3 entries to your blog at any one time. If you would like to update your blog please delete one of the older entries."; } else{ echo" <form method='post' action='my_profile_blog_submit.php'> <table class='myprofile_blog'> <tr><td class='myprofile_subtext'>Subject :</td><td class='myprofile_blogsub'> <input name='Blog_subject' type='text' style='width: 413px' /></td></tr> <tr><td class='myprofile_subtext' style='width: 120px' valign='top'>Message :</td><td> <textarea name='Blog_message' style='width: 505px; height: 152px'></textarea></td></tr> </table> <br /> <br /> <br /> <table> <tr><td class='myprofile_changesh'>Add a new entry to your Blog ...</td><td class='myprofile_changesh'> </td></tr> <tr><td class='myprofile_subsub'>Add another entry to your blog. Please delete the older entries that are outdated and try and get it to a limit of 3 or 4 entries.</td></tr> <tr><td colspan='2'></td></tr> </table> <br /> <table class='myprofile_change'> <tr><td><input class='submit_blog' name='addblog' type='submit' value='Post that shit' /></td></tr> </table> </form> "; } ?>
  14. If i use this code it echo's that there is 3 blog entries for this user. <?php include("config_contact.php"); $username=$_SESSION['myusername']; // Retrieve data from database $sql = "SELECT count(Blog_username) as blogcount FROM User_blogT WHERE Blog_username='$username' "; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); if($row['blogcount'] > 0) { echo "(" . $row['blogcount'] . ")"; } ?> But using this code the form just always shows up! can anyone see whats wrong? <?php include("config_contact.php"); $username=$_SESSION['myusername']; // Retrieve data from database $sql = "SELECT count(Blog_username) as blogcount FROM User_blogT WHERE Blog_username='$username' "; $result = mysql_query($sql); if($row['blogcount'] > 3){ echo "You are only allowed to Have 3 entries to your blog at any one time. If you would like to update your blog please delete one of the older entries."; } else{ echo" <form method='post' action='my_profile_blog_submit.php'> <table class='myprofile_blog'> <tr><td class='myprofile_subtext'>Subject :</td><td class='myprofile_blogsub'> <input name='Blog_subject' type='text' style='width: 413px' /></td></tr> <tr><td class='myprofile_subtext' style='width: 120px' valign='top'>Message :</td><td> <textarea name='Blog_message' style='width: 505px; height: 152px'></textarea></td></tr> </table> <br /> <br /> <br /> <table> <tr><td class='myprofile_changesh'>Add a new entry to your Blog ...</td><td class='myprofile_changesh'> </td></tr> <tr><td class='myprofile_subsub'>Add another entry to your blog. Please delete the older entries that are outdated and try and get it to a limit of 3 or 4 entries.</td></tr> <tr><td colspan='2'></td></tr> </table> <br /> <table class='myprofile_change'> <tr><td><input class='submit_blog' name='addblog' type='submit' value='Post that shit' /></td></tr> </table> </form> "; } ?>
  15. Ok ive got it showing up now, but when i added the third entry it still shows up ??? <br /> <?php include("config_contact.php"); $username=$_SESSION['myusername']; // Retrieve data from database $sql = "SELECT count(Blog_username) as blogcount FROM User_blogT WHERE Blog_username='$username' "; $result = mysql_query($sql); if($row['blogcount'] >= 3) { echo "You are only allowed to Have 3 entries to your blog at any one time. If you would like to update your blog please delete one of the older entries."; } else{ echo" <form method='post' action='my_profile_blog_submit.php'> <table class='myprofile_blog'> <tr><td class='myprofile_subtext'>Subject :</td><td class='myprofile_blogsub'> <input name='Blog_subject' type='text' style='width: 413px' /></td></tr> <tr><td class='myprofile_subtext' style='width: 120px' valign='top'>Message :</td><td> <textarea name='Blog_message' style='width: 505px; height: 152px'></textarea></td></tr> </table> <br /> <br /> <br /> <table> <tr><td class='myprofile_changesh'>Add a new entry to your Blog ...</td><td class='myprofile_changesh'> </td></tr> <tr><td class='myprofile_subsub'>Add another entry to your blog. Please delete the older entries that are outdated and try and get it to a limit of 3 or 4 entries.</td></tr> <tr><td colspan='2'></td></tr> </table> <br /> <table class='myprofile_change'> <tr><td><input class='submit_blog' name='addblog' type='submit' value='Post that shit' /></td></tr> </table> </form> "; } ?>
  16. Ok i have tried this method but its displaying nothing at all. <?php include("config_contact.php"); $username=$_SESSION['myusername']; // Retrieve data from database $sql = "SELECT count(Blog_username) as blogcount FROM User_blogT WHERE Blog_username='$username' "; $result = mysql_query($sql); if($result->numRows() > 3) { echo "You are only allowed to Have 3 entries to your blog at any one time. If you would like to update your blog please delete one of the older entries."; } else{ echo" <form method='post' action='my_profile_blog_submit.php'> <table class='myprofile_blog'> <tr><td class='myprofile_subtext'>Subject :</td><td class='myprofile_blogsub'> <input name='Blog_subject' type='text' style='width: 413px' /></td></tr> <tr><td class='myprofile_subtext' style='width: 120px' valign='top'>Message :</td><td> <textarea name='Blog_message' style='width: 505px; height: 152px'></textarea></td></tr> </table> <br /> <br /> <br /> <table> <tr><td class='myprofile_changesh'>Add a new entry to your Blog ...</td><td class='myprofile_changesh'> </td></tr> <tr><td class='myprofile_subsub'>Add another entry to your blog. Please delete the older entries that are outdated and try and get it to a limit of 3 or 4 entries.</td></tr> <tr><td colspan='2'></td></tr> </table> <br /> <table class='myprofile_change'> <tr><td><input name='addblog' type='submit' value='Post that shit' /></td></tr> </table> </form> "; } ?> and yes i have echo's the blogcount and it is reconsiing the amount of entries i have.
  17. Ok basically what i am trying to do is for the my profile, manage my blog section of my site i only want users to be able to have a maximum of 3 blog entries at any one time. So i want to use a count command to check if they already have 3 entries and if so echo a message, but if they have less than 3 entries echo the add a new entry form. This is as far as i have got but ive been trying so long i have confused myself so now i need some help please. <?php include("config_contact.php"); $username=$_SESSION['myusername']; // Retrieve data from database $sql = "SELECT count(Blog_username) as blogcount FROM User_blogT WHERE Blog_user='$username' "; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); if($row['blogcount'] != 3) { echo "You are only allowed to Have 3 entries to your blog at any one time. If you would like to update your blog please delete one of the older entries."; } else{ echo" <form method='post' action='my_profile_blog_submit.php'> <table class='myprofile_blog'> <tr><td class='myprofile_subtext'>Subject :</td><td class='myprofile_blogsub'> <input name='Blog_subject' type='text' style='width: 413px' /></td></tr> <tr><td class='myprofile_subtext' style='width: 120px' valign='top'>Message :</td><td> <textarea name='Blog_message' style='width: 505px; height: 152px'></textarea></td></tr> </table> <br /> <br /> <br /> <table> <tr><td class='myprofile_changesh'>Add a new entry to your Blog ...</td><td class='myprofile_changesh'> </td></tr> <tr><td class='myprofile_subsub'>Add another entry to your blog. Please delete the older entries that are outdated and try and get it to a limit of 3 or 4 entries.</td></tr> <tr><td colspan='2'></td></tr> </table> <br /> <table class='myprofile_change'> <tr><td><input name='addblog' type='submit' value='Post that shit' /></td></tr> </table> </form> "; } ?>
  18. Ok ive worked it out for myself and got it working. Thankyou for everyone that helped i appreciate it. For anyone that cares hear is the working code. <?php $username=$_SESSION['myusername']; if(isset($_SESSION['myusername'])) { echo " <img alt='' src='../icons/myacc.gif' width='12' height='11' /> <a class='button6' href='my_profile.php'>My Account</a> <img alt='' src='../icons/mypro.gif' width='12' height='11' /> <a class='button6' href='profile.php?username=$username'>My Profile</a> <img alt='' src='../icons/mymes.gif' width='12' height='11' /> <a class='button6' href='my_profile_messages.php'>My Messages</a> <img alt='' src='../icons/myale.gif' width='11' height='11' /> <a class='button6' href='my_profile_alerts.php'>My Alerts</a> <img alt='' src='../icons/myreq.gif' width='12' height='11' /> <a class='button6' href='my_profile_requests.php'>My Requests</a> <img alt='' src='../icons/myfri.gif' width='12' height='11' /> <a class='button6' href='my_profile_friends.php'>My Friends</a> <img alt='' src='../icons/mylog.gif' width='12' height='12' /> <a class='button6' href='logout.php'>Logout</a> "; } else{ echo " <form method='post' action='check_login.php'> <table style='float: right'> <tr> <td><input class='username' name='myusername' type='text' value='Username'/></td> <td class='logmein'>:Username</td> <td><input class='password' name='mypassword' type='password' value='Password'/></td> <td class='logmein'>:Password</td> <td><input class='submit' name='Submit2' type='submit' value='Cumon in'/><a href='user_register.htm'><input class='register' name='Submit2' type='button' value='Register'/></a></td> </tr> </table> </form> "; } ?>
  19. Ok what a dick lol ive added the echo but it still isnt working. I have my session start at the very beginning of the page so thats not the problem! any ideas? again thanks for your patience! <?php if(isset($_SESSION['myusername'])) { echo " <img alt='' src='../icons/myacc.gif/' width='12' height='11' /> <a class='button6' href='my_profile.php'>My Account</a> <img alt='' src='../icons/mypro.gif' width='12' height='11' /> <a class='button6' href='profile.php'>My Profile</a> <img alt='' src='../icons/mymes.gif' width='12' height='11' /> <a class='button6' href='my_profile_messages.php'>My Messages</a> <img alt='' src='../icons/myale.gif' width='11' height='11' /> <a class='button6' href='my_profile_alerts.php'>My Alerts</a> <img alt='' src='../icons/myreq.gif' width='12' height='11' /> <a class='button6' href='my_profile_requests.php'>My Requests</a> <img alt='' src='../icons/myfri.gif' width='12' height='11' /> <a class='button6' href='my_profile_friends.php'>My Friends</a> <img alt='' src='../icons/mylog.gif' width='12' height='12' /> <a class='button6' href='logout.php'>Logout</a> "; } else{ echo " <form method='post'> <table style='float: right'> <tr> <td><input class='username' name='username' type='text' value='Username'/></td> <td class='logmein'>:Username</td> <td><input class='password' name='Password1' type='password' value='Password'/></td> <td class='logmein'>:Password</td> <td><input class='submit' name='Submit2' type='submit' value='C'umon in'/><a href='user_register.htm'"><input class='register' name='Submit2' type='button' value='Register'/></a></td> </tr> </table> </form> "; } ?>
×
×
  • 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.