PHP - Php Trade System Not Working?
Hello. I've been having trouble with this trade system not working(my friend made it). Most of it is functioning properly, except the part where it's supposed to show your partners pokemon box. Here is the code:
<?php require_once("top_header.php"); if(!isset($_GET["p"]) && !isset($_GET["id"]) && !isset($_GET["submit"])) { ?> <form action="trading.php" method="get"> Please enter the ID of the person you would like to trade:<br /> <input type="text" name="p" /><br /> <input type="submit" value="Continue!" /><br /> </form> <table width=100%> <tr> <td class="header">Trade Partners:</td> <td class="header">Open Trades:</td> </tr> <?php $check1 = "SELECT trade_id, starter_id FROM trades WHERE partner_id = $id AND status = 0"; $check2 = mysql_query($check1); while($row = mysql_fetch_array($check2)) { $ass = mysql_fetch_array(mysql_query("SELECT username FROM users WHERE id = {$row["starter_id"]}")); echo "<tr>"; echo "<td class=into>"; echo $ass["username"]; echo "</td>"; echo "<td class=into>"; echo "<a href=trading.php?id={$row["trade_id"]}>View Trade!</a>"; echo "</td>"; echo "</tr>"; } ?> <tr> <td class="header">Created To:</td> <td class="header">Options:</td> </tr> <?php $check1 = "SELECT trade_id, partner_id FROM trades WHERE starter_id = $id AND status = 0"; $check2 = mysql_query($check1); while($row = mysql_fetch_array($check2)) { $ass = mysql_fetch_array(mysql_query("SELECT username FROM users WHERE id = {$row["partner_id"]}")); echo "<tr>"; echo "<td class=into>"; echo $ass["username"]; echo "</td>"; echo "<td class=into>"; echo "<a href=delete.php?id={$row["trade_id"]}>Delete Trade!</a>"; echo "</td>"; echo "</tr>"; } ?> </table> <?php } else if(isset($_GET["p"])) { $check = mysql_num_rows(mysql_query("SELECT username FROM users WHERE id = ".$_GET['p']."")); if($check <= 0) { echo "Please do not try to trade non existant users!"; include('bottom_layout.php'); die(); } ?> <form action="trading.php?submit" method="post"> <b>Your Pokemon:</b><br> <select width="100px" size=15 name="starter[]" multiple="multiple"> <option value="0" selected>None</option> <?php $query = mysql_query("SELECT id, nickname, level FROM pokemon WHERE owner_id= $id AND slot = 7"); while($info = mysql_fetch_assoc($query)) { ?> <option value="<?php echo $info["id"] ?>"><?php echo $info["nickname"] ?> level:<?php echo $info["level"]?></option> <?php } ?> </select> <br><br><br> <b>Partners Pokemon</b><br> <select width="100px" size=15 name="partner[]" multiple="multiple"> <option value="0" selected>None</option> <?php $p = htmlentities($_GET["p"]); $sql = "SELECT id, gender, pokedex_id, type, level FROM pokemon WHERE owner_id = $p AND slot = 7 AND status = 1"; $starter_pokemon = mysql_query($sql); while($row = mysql_fetch_assoc($starter_pokemon)) { $name = mysql_fetch_assoc(mysql_query("SELECT name FROM pokedex WHERE id={$row["pokedex_id"]}")); $type = mysql_fetch_assoc(mysql_query("SELECT name FROM types WHERE id={$row["type"]}")); $name = $type["name"].$name["name"]; ?> <option value="<?php echo $info["id"] ?>"><?php echo $info["nickname"] ?> level:<?php echo $info["level"]?></option> <?php } ?> </select><br /> <input type="submit" value="Send Trade!" /> <input type="hidden" name="p_id" value="<?php echo $_GET["p"];?>" /> </form> <?php } else if(isset($_GET["submit"])) { $status = 0; $partner = mysql_real_escape_string($_POST["p_id"]); foreach($_POST["starter"] as $pokemon) { $pokemon = mysql_real_escape_string($pokemon); $result = mysql_query("SELECT id FROM pokemon WHERE owner_id = $id AND id = $pokemon"); if(mysql_num_rows($result) == 0 && $pokemon != 0) { $status = 5; } } foreach($_POST["partner"] as $pokemon) { $pokemon = mysql_real_escape_string($pokemon); $result = mysql_query("SELECT id FROM pokemon WHERE owner_id = $partner AND id = $pokemon"); if(mysql_num_rows($result) == 0 && $pokemon != 0) { $status = 5; } } $starter_pokemon = json_encode($_POST["starter"]); $partner_pokemon = json_encode($_POST["partner"]); if($starter_pokemon == "[\"0\"]" && $partner_pokemon == "[\"0\"]") { echo "Sorry, one of you has to be trading something!"; } $sql = "INSERT INTO trades (starter_id, starter_pokemon, partner_id, partner_pokemon, status) VALUES ($id, '".mysql_real_escape_string($starter_pokemon)."', $partner, '".mysql_real_escape_string($partner_pokemon)."', $status)"; mysql_query($sql); echo "Trade created!"; } else if(isset($_GET["id"])) { $trade = mysql_real_escape_string($_GET["id"]); $sql = "SELECT * FROM trades WHERE trade_id = $trade"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); $starter_pokemon = json_decode($row["starter_pokemon"]); $partner_pokemon = json_decode($row["partner_pokemon"]); echo "<h3>You are Trading:</h3>"; foreach($partner_pokemon as $pokeid) { $pokeinfo = mysql_fetch_assoc(mysql_query("SELECT pokedex_id, gender, type, level FROM pokemon WHERE id = $pokeid")); $name = mysql_fetch_assoc(mysql_query("SELECT name FROM pokedex WHERE id = {$pokeinfo["pokedex_id"]}")); $type = mysql_fetch_assoc(mysql_query("SELECT name FROM types WHERE id = {$pokeinfo["type"]}")); echo $type["name"].$name["name"]." ({$pokeinfo["gender"]}) (Level:{$pokeinfo["level"]})<br />"; } echo "<h3>Your Partner is Trading:</h3>"; foreach($starter_pokemon as $pokeid) { $pokeinfo = mysql_fetch_assoc(mysql_query("SELECT pokedex_id, gender, type, level FROM pokemon WHERE id = $pokeid")); $name = mysql_fetch_assoc(mysql_query("SELECT name FROM pokedex WHERE id = {$pokeinfo["pokedex_id"]}")); $type = mysql_fetch_assoc(mysql_query("SELECT name FROM types WHERE id = {$pokeinfo["type"]}")); echo $type["name"].$name["name"]."({$pokeinfo["gender"]}) (Level:{$pokeinfo["level"]})<br />"; } ?> <br><br> <a href=complete.php?id=<?php echo $row['trade_id']; ?>>Complete the trade!</a><br><a href=delete.php?id=<?php echo $row['trade_id']; ?>>Delete the trade!</a> </table> <?php } require_once("bottom_layout.php"); ?> Similar TutorialsAlright first off, I don't know if this is a PHP or SQL problem. Second, I am not very knowledgeable in this subject at all the only reason I'm trying to get this to work is cause my buddy's computer is broken so he can't do much of anything (Would let him use mine but he lives half way across the country from me). So jumping right to the point we purchased this website about a month back cause it was going downhill and we thought this would be a great base to start from. So the following PHP script IS NOT written by us. Since i cant paste the script without it being a wall of text I'll have to tell you the issue BEFORE i post it. When you create the trade for example: Your Oddish His Squirtle It shows that but when you make ANOTHER separate trade for example: Your Lugia His Ho-Oh <-------------That's how it SHOULD look but it goes like this instead: Your Oddish Lugia His Squirtle Ho-Oh Now when you make the trade it adds into the SQL "traded" 1 instead of 0 so i was wondering if from the list of available Pokemon for trade if i could just have any Pokemon that has "Traded" as 1 to be removed from the list BUT NOT FROM THE GAME! Lol i tried DELETE FROM `poke_owned` WHERE `traded`='1' And lets just say that it didn't turn out well.... Now i don't know how much information your going to need so if you need more than just the trade script tell me. Code: [Select] <?php session_start(); require_once 'dbconf.php'; include("figg.php"); if(!isset($_SESSION['user'])){ ?> <script language="text/javascript"> alert('You are not logged in.'); </script><? header ("Location: login.php"); } else{ session_start(); $snorretje1 = mysql_query("SELECT * FROM `users` WHERE `username`='" . $_SESSION['user'] . "'"); $snorretje = mysql_fetch_object($snorretje1); $user1 = mysql_query("SELECT * FROM `users` WHERE `id`='$snorretje->id'"); $user = mysql_fetch_object($user1); require_once 'figg.php'; $pokemon1 = mysql_query("SELECT * FROM `poke_owned` WHERE `trainer`='$user->username' AND `party1`='1'"); $pokemon = mysql_fetch_object($pokemon1); $poke1 = mysql_query("SELECT * FROM `pokemon` WHERE `name`='$pokemon->name'"); $poke = mysql_fetch_object($poke1); $amo1= mysql_query("SELECT * FROM `poke_owned` WHERE `trainer`='$user->username'"); $amo=mysql_num_rows($amo1); $trading1=mysql_query("SELECT * FROM `users` WHERE `id`='" . $_GET['q'] . "'"); $trading=mysql_fetch_object($trading1); $traderss1=mysql_query("SELECT * FROM `poke_owned` WHERE `box`='1' AND `trainer`='" . $trading->username . "' ORDER BY `name` ASC"); $traderss=mysql_fetch_object($traderss1); $owntraderss1=mysql_query("SELECT * FROM `poke_owned` WHERE `box`='1' AND `trainer`='" . $user->username . "' ORDER BY `name` ASC"); $owntraderss=mysql_fetch_object($owntraderss1); $nummer=mysql_num_rows($traderss1); ?> <?include("leftmenu.php");?> <?if($_GET['q']==""){?> <div class="title">Trade pokemon</div> <div class="contentcontent"> <br> <center> <?if(!isset($_POST['mytrade'])){ if(!isset($_POST['othertrade'])){?> Please enter the number of the trainer you would like to trade with:<br> <br> <form name="form" action="trade5.php" method="get"> <input type="text" name="q" /> <input type="submit" name="Submit" value="Trade" class="button" /> </form> <?}}}?> <?if($_GET['q']!=""){ if ($user->id == $_GET['q']) { echo "<div class=\"contentcontent\"><p class=\"title\">Trade pokemon</p><br><center>You can't trade yourself... Silly buns...</center></div>"; include("rightmenu.php"); exit; } $trading1=mysql_query("SELECT * FROM `users` WHERE `id`='" . $_GET['q'] . "'"); $trading=mysql_fetch_object($trading1); $trading1=mysql_query("SELECT * FROM `users` WHERE `id`='" . $_GET['q'] . "'"); $num=mysql_num_rows($trading1); if($num==0){echo("<center><b>No user found with that ID.</b></center>");} if($num==1){ ?> <div class="contentcontent"><p class="title">Trade pokemon with trainer #<?=$_GET['q']?></p> <form action="/trade5.php?a=<?=$_GET['q']?>" method="POST"><table class="w100"><tr><td class="w50"><p class="center">Your Pokémon<br /><select name="mytrade[]" multiple="multiple" size="20"><option value="niks" selected>(No Pokémon)</option><?while($owntradert=mysql_fetch_object($owntraderss1)){?><option value="<?=$owntradert->id?>"><?=$owntradert->name?> <?=$owntradert->gender?> (Level:<?=$owntradert->level?>)</option><?}?></select></p></td> <td class="w50"><p class="center"><?=$trading->username?>'s Pokémon<br /><select name="othertrade[]" multiple="multiple" size="20"><option value="niks" selected>(No Pokémon)</option><?while($tradert=mysql_fetch_object($traderss1)){?><option value="<?=$tradert->id?>"><?=$tradert->name?> <?=$tradert->gender?> (Level:<?=$tradert->level?>)</option><?}?></select></p></td></table> <center><input type="submit" value="Trade"> <?}} $bs=2; if ($bs == 1) { ?> ' <? } if(isset($_POST[mytrade])){ { $trading1=mysql_query("SELECT * FROM `users` WHERE `id`='" . $_GET['a'] . "'"); $trading=mysql_fetch_object($trading1); $id1=mysql_query("SELECT * FROM `trade`"); $id=mysql_fetch_object($id1); $numbl=mysql_num_rows($id1); if($numbl==0) { $tradeid=0; } else { $tradeid=$id->tradeid+1; } $ytrade=$_POST[mytrade]; if($ytrade){ foreach ($ytrade as $y) mysql_query("INSERT INTO `trade` (`from`, `to`, `pokid`,`tradeid`,`owner`) values('" . $user->id . "','" . $_GET['a'] . "','" . $y . "','" . $tradeid . "','" . $user->id . "')")or die(mysql_error()); $theother1=mysql_query("SELECT * FROM `users` WHERE `id`='" . $_GET['a'] . "'"); $theother=mysql_fetch_object($theother1); $error1=mysql_query("SELECT * FROM `poke_owned` WHERE `trainer`='" . $theother->username . "' AND `id`='" . $y . "' OR `trainer`='" . $user->username . "' AND `id`='" . $y . "'"); $error=mysql_num_rows($error1); if($error==0 && $y!=niks) { echo("Don't try to cheat!"); exit; } } if($ytrade){ foreach ($ytrade as $y) mysql_query("UPDATE poke_owned SET traded=1 WHERE id='" . $y . "'"); mysql_query("DELETE FROM `trade` WHERE `pokid`='niks'"); } { } } $otrade=$_POST[othertrade]; if($otrade){ foreach ($otrade as $o) mysql_query("INSERT INTO `trade` (`from`, `to`, `pokid`,`tradeid`, `owner`) values('" . $user->id . "','" . $_GET['a'] . "','" . $o . "','" . $tradeid . "','" . $_GET['a'] . "')")or die(mysql_error()); $theother1=mysql_query("SELECT * FROM `users` WHERE `id`='" . $_GET['a'] . "'"); $theother=mysql_fetch_object($theother1); $error1=mysql_query("SELECT * FROM `poke_owned` WHERE `trainer`='" . $theother->username . "' AND `id`='" . $o . "' OR `trainer`='" . $user->username . "' AND `id`='" . $y . "'"); $error=mysql_num_rows($error1); if($error==0 && $o!=niks) { echo("Don't try to cheat!"); exit; } } if($otrade){ foreach ($otrade as $o) mysql_query("UPDATE poke_owned SET traded=1 WHERE id='" . $o . "'"); mysql_query("DELETE FROM `trade` WHERE `pokid`='niks'"); } unset($_POST[mytrade]); unset($_POST[othertrade]); ?><meta http-equiv="Refresh" content="0; url=/traded.php"><? } ?> <br> <p> </p> <p class="center"> </p> </div> <?include("rightmenu.php");?> </html> <?}?> For some reason my email system isnt working, but no errors are showing up and i cant seem to find a syntax error. I need some fresh eyes to help to solve this... Code: [Select] <?php if(isset($_POST['PersonName'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "j.hopley@2008.ljmu.ac.uk"; $email_subject = "An email from your blog."; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_POST['PersonName']) || !isset($_POST['PersomComment']) || !isset($_POST['PersonEmail']) || !isset($_POST['PersonNumber'])) { died('We are sorry, but there appears to be a problem with the form you submitted. One or more fields were empty or contained invailid charicters.'); } $person_name = $_POST['PersonName']; // required $person_comment = $_POST['PersomComment']; // required $person_email = $_POST['PersonEmail']; // required $person_number = $_POST['PersonNumber']; // not required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$person_email)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$person_name)) { $error_message .= 'The Name you entered does not appear to be valid.<br />'; } if(strlen($person_comment) < 2) { $error_message .= 'The Comments you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "First Name: ".clean_string($person_name)."\n"; $email_message .= "Email: ".clean_string($person_email)."\n"; $email_message .= "Telephone: ".clean_string($person_number)."\n"; $email_message .= "Comments: ".clean_string($person_comment)."\n"; // create email headers $headers = 'From: '.$person_email."\r\n". 'Reply-To: '.$person_email."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); } ?> Hi, I made a login/register system and it was working fine, but now I seem to have broken it and I'm scratching my head as to why. I think it's something to do with the $_SESSION array, the error happens from going from the login.php page to members.php, I log in successfully, but when I get to the members page it says "you must be logged in". index.php has the form to login or a link to register.php to make an account Code: [Select] <?php session_start(); ?> <html> <head> <title>Lincs Crusade | Login page.</title> </head> <body> <form action="login.php" method="POST"> Username: <input type="text" name="username"><br /> Password: <input type="password" name="password"><br /> <input type="submit" value="Login"> </form> <a href="register.php">Click here to register!</a> </body> </html> The register.php page Code: [Select] <?php session_start(); echo "<h2>Register</h2>"; $submit = $_POST['submit']; $username = strip_tags($_POST['username']); $password = strip_tags($_POST['password']); $repeatpassword = strip_tags($_POST['repeatpassword']); $email = $_POST['email']; $date = date("Y-m-d"); if ($submit) { if ($username&&$password&&$repeatpassword&&$email) { if ($password==$repeatpassword) { if (strlen($username)>65) { echo "Length of username is too long!"; } elseif (strlen($email)>100) { echo "Length of email is too long!"; } elseif (strlen($password)>65||strlen($password)<8) { echo "Password must be between 8 and 65 characters long!"; } else { include('functions.php'); echo "All fields were accepted! "; $password = md5($password); $repeatpassword = ($repeatpassword); $email = md5($email); connect(); mysql_query(" INSERT INTO users VALUES ('','$username','$password','$email','$date') ") or die("Could not insert values into <em>users</em> table!"); mysql_query(" INSERT INTO stats VALUES ('$username',10,10,0,1) ") or die("Could not insert values into <em>stats</em> table!"); $_SESSION['username'] == $username; die("You have been registered! Please return to <a href=\"index.php\">homepage</a> and login."); } } else { echo "Your passwords do not match!"; } } else { echo "Please fill in <em>all</em> fields!"; } } ?> <html> <head> <title>Lincs Crusade | Register an Account.</title> </head> <body> <form action="register.php" method="POST"> <p>Your username:</p> <p>Note: Do not use your real name.</p> <input type="text" name="username" value="<?php echo $username ?>"/>= <p>Choose a password:</p> <input type="password" name="password" /> <p>Please repeat password:</p> <input type="password" name="repeatpassword" /> <p>Your student email:</p> <p>Note: This is only used for recovering a lost or forgotten password.</p> <input type="text" name="email" /><br /> <input type="submit" value="Register" name="submit" /> <p> Note: Your password and email are md5 encrypted. This means neither I (the author) or anyone else will be able to view your information<br /> in plain text. For example, your password or email will look something like this "534b44a19bf18d20b71ecc4eb77c572f" once it has been encrypted. </p> </form> </body> </html> The login.php page that process the form data to access members.php page Code: [Select] <?php session_start(); $username = $_POST['username']; $password = $_POST['password']; if ($username&&$password) { include('functions.php'); connect(); $query = mysql_query("SELECT * FROM users WHERE username='$username'"); $numrow = mysql_num_rows($query); if ($numrow!=0) { while ($row = mysql_fetch_assoc($query)) { $dbusername = $row['username']; $dbpassword = $row['password']; } if ($username==$dbusername&&md5($password)==$dbpassword) { echo "You're in! - <a href=\"members.php\">Proceed to the members page</a>"; $_SESSION['username'] == $username; } else { echo "Incorrect password!"; } } else { die ("That user doesn't exist,<a href=\"register.php\">please register an account</a>"); } } else { die("Please enter a username and password!"); } ?> The members.php page Code: [Select] <?php session_start(); ?> <html> <head> <title>Lincs Crusade | Members page.</title> </head> <body> <?php if ($_SESSION['username']) { echo "Welcome," .$_SESSION['username']. "!<br />"; echo "<a href=\"stats.php\">View your stats.</a>"; } else { die ("You must be logged in."); } ?> </body> </html> and this is what is in the functions.php file Code: [Select] <?php function connect() { mysql_connect("localhost","root","password") or die ("Unable to connect"); mysql_select_db("database") or die ("Unable to find database"); } ?> Thanks for your help. Hi im pretty new to php but I was following a tutorial for a commenting system and implemented it onto my blog page. Anyway the problem I have is that as you go down the page each blog post displays its own comments + the comments for the posts above it. I have checked the database and the data seems to link the correct comments to the correct posts so I am confused to why this is happening. I have looked over my code and cant seem to find a problem (probably because I suck!). Here is the code for the blog page... Code: [Select] <?php include_once ("scripts/checkuserlog.php"); include_once ("scripts/connectToMysql.php"); include_once ("functions/agoTime.php"); $myObject = new convertToAgo; $username = ''; $errorMsg = ''; $successMsg = ''; $date = date("m.d.y"); if (isset($_GET['id'])) { $id = preg_replace('#[^0-9]#i', '', $_GET['id']); } else if (isset($_SESSION['idx'])) { $id = $logOptions_id; } else { header("location: index.php"); exit(); } $id = preg_replace('#[^0-9]#i', '', $id); $sql = mysql_query("SELECT * FROM members WHERE id='$id' LIMIT 1"); $existCount = mysql_num_rows($sql); if ($existCount == 0) { header("location: index.php?msg=user_does_not_exist"); exit(); } while($row = mysql_fetch_array($sql)){ $username = $row["username"]; } if(isset($_POST['workoutName'])){ $workoutName = $_POST['workoutName']; $workoutDescription = $_POST['workoutDescription']; if ((!$workoutName) || (!$workoutDescription)) { $errorMsg = 'Please fill in both fields'; } else { $insertBlog = mysql_query("INSERT INTO blog (userid, workoutName, workoutDescription, datetime) VALUES ('$id', '$workoutName', '$workoutDescription', now())") or die(mysql_error()); if ($insertBlog){ $successMsg = '<span class="errorMsg">Workout blogged successfully</span>'; } else { $errorMsg = '<span class="errorMsg">Problems arose during the information exchange, please try again later.</span>'; } } } $getBlog = mysql_query("SELECT * FROM blog WHERE userid='$id' ORDER BY id DESC"); $blogEntries = mysql_num_rows($getBlog); if($blogEntries < 1){ $blogDisplay = '<span class="blogName">' .$username. ' has not blogged a workout yet</span>'; } else { while($row = mysql_fetch_array($getBlog)){ $blogEntryId = $row["id"]; $sql_comment = mysql_query("SELECT * FROM blog_comments WHERE post_id='$blogEntryId' ORDER BY id ASC"); $countComment = mysql_num_rows($sql_comment); if($countComment > 0){ while($row2 = mysql_fetch_array($sql_comment)){ $comment_user_id = $row2["comment_user_id"]; $sql_comment_username = mysql_query("SELECT username FROM members WHERE id='$comment_user_id' LIMIT 1"); while($row3 = mysql_fetch_array($sql_comment_username)){ $comment_username = $row3["username"];} $post_id = $row2["post_id"]; $commentBody = $row2["comment_body"]; $commentDate = $row2["comment_date"]; $displayCommentList .= '<div>' .$comment_username. ' - ' .$commentBody. ' - ' .$commentDate. '</div>'; } } else { $displayCommentList = ''; } $workoutName = $row["workoutName"]; $workoutDescription = $row["workoutDescription"]; $blogDate = $row["datetime"]; $convertedTime = ($myObject -> convert_datetime($blogDate)); $blogDate = ($myObject -> makeAgo($convertedTime)); $blogDisplay .= '<table width="950px"><tr bgcolor="#DBE4FD"><td><span class="blogName">' .$workoutName. '</span> » <span class="blogDate">' .$blogDate. '</span></td></tr> <tr bgcolor="#F1F4FE"><td><span class="blackText">' .$workoutDescription. '</span></td></tr> <tr bgcolor="#DBE4FD" valign="top"><td>' .$displayCommentList. '</td></tr> <div id="new_comment' .$blogEntryId. '" style="display:none"></div> <tr><td><textarea id="comment' .$blogEntryId. '"></textarea><input type="submit" value="Comment" onclick="javascript:SendComment(\''.$blogEntryId.'\');" /></td></tr>'; if(isset($_SESSION['id'])&&$_SESSION['id']==$id){ $blogDisplay .= '<tr bgcolor="#DBE4FD"><td><a href="editBlogPost.php?id=' .$blogEntryId. '"><span class="blackText">Edit Post</span></a> &#8211; <span class="blackText">Delete Post</span></td></tr></table><br /><br />'; } } } if(isset($_POST['deleteButton'])){ $deleteBlog = mysql_query("DELETE FROM blog WHERE id='$blogEntryId'"); if($deleteBlog){ $successMsg = 'Blog entry deleted successfully'; } else { $errorMsg = 'Could not process your request, please try again later'; } } ?> <?php if (isset($_SESSION['id'])&&$_SESSION['id']==$id) { $blogForm = '<table bgcolor="#DBE4FD" width="950px"> <form action="member_blog.php" method="post" enctype="multipart/form-data"> <tr> <td width="200px"><span class="blackText">Workout Name:</span></td><td width="650px"><input name="workoutName" type="text" id="workoutName" /> <span class="blackText">Date: ' .$date. '</span></td></tr> <tr> <td><span class="blackText">Workout Description:</span></td><td><textarea name="workoutDescription" cols="75" rows="10" id="workoutDescription" /></textarea></td></tr> <tr><td><input name="submitBlog" id="submit" type="submit" value="Blog!" /></td><td><span class="errorMsg">' .$errorMsg. '' .$successMsg. '</span></td> </tr> </form> </table>'; } else { $blogForm = ''; } ?> <!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=utf-8" /> <title><?php echo ("$username"); ?>'s Blog</title> <link href="style/layout.css" rel="stylesheet" type="text/css" /> <link href="style/main.css" rel="stylesheet" type="text/css" /> <script src="js/jquery-1.4.2.js" type="text/javascript"></script> <script language="javascript" type="text/javascript"> function SendComment(blogEntryId){ var comment_txt = $("#comment"+blogEntryId).val(); if(comment_txt == ""){ alert("Please enter a comment"); } else { $.post("scripts/blogComment.php", {comment: comment_txt, blogId: blogEntryId} ,function(data){ $("#new_comment"+blogEntryId).html(data); $("#new_comment"+blogEntryId).slideDown(300); }); } } </script> </head> <body> <div id="container"> <?php include_once ("bannerFiles/bannerTemplate.php"); ?> <?php include_once ("bannerFiles/bannerMenu.php"); ?><br /> <div id="content"> <span class="profileUsername"><?php echo ("$username"); ?>'s Workout Blog</span><br /><br /> <?php echo ("$blogDisplay"); ?><br /><br /> <?php echo ("$blogForm"); ?> </div><br /><br /> <?php include_once ("footerFiles/footerTemplate.php"); ?> </div> </body> </html> ...and here is the code for the blogComment.php page Code: [Select] <?php session_start(); include_once ("connectToMysql.php"); if(isset($_POST['comment'])){ $comment = $_POST['comment']; $blogId = $_POST['blogId']; $comment_user_id = $_SESSION['id']; $username = $_SESSION['username']; $sql = mysql_query("INSERT INTO blog_comments (comment_body, post_id, comment_user_id, comment_date) VALUES ('$comment', '$blogId', '$comment_user_id', now())"); echo '<div>' .$username. ' - ' .$comment. ' - Just Now</div>'; } else { echo "Failure"; } ?> Thanks in advance for any help This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=348317.0 hello dear PHP-Fans - greetings to you - and a happy new year!! i set up a WAMP-System on my openSuse 11.4 system. In order to learn as much as i can bout PHP i want to do some tests and write some scripts. Well the WAMP is allready up and running. Now i try to give the writing access to the folder mkdir /srv/www/ where the php-scripts should go in... i want to give write permission to all to all files in /srv/www As root I generally: mkdir /srv/www/ chown <webmaster usrername> /srv/www/ /srv/www/ should be readable and traversable by all, but only writeable by it's owner (the user designated as the webmaster.) can i do this like mentioned above,... Love to hear from you greetings db1 Hi all I have been looking though loads of tutorials regarding log in method for websites (not APIs), and cant help find that they are outdated. So I am asking what is the correct way to create a log in system using php? Modern websites use JavaScript for asynchronous web requests so this requirement should also be catered for. APIs and mobile apps use access tokens which is very secure if implemented correctly. Can we use the token principle for websites? As the way I see it that most php log in systems use php sessions and they create a session and save some data in this session when the user successfully authenticates, however the session id is held in a cookie so if the cookie is stolen then they have access to your account. API access tokens are expired and refreshed periodically so is there such a implementation method for web sites too?
Hi this is my login script i do have the html if you need to see it please ask & i was wondering if anyone would be kind enough to tell me how i can get my ban system to work Thanks
<?php require 'connect.php'; if(isset($_POST['submit'])) { $username = $_POST['username']; $password = $_POST['password']; //Prevent hackers from using SQL Injection $username = stripslashes($username); $password = stripslashes($password); $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); $sql = "SELECT * FROM $tbl_name WHERE username='$username' AND password='$password'"; $result = mysql_query($sql); $count = mysql_num_rows($result); $user_level = $_GET['user_level']; $_SESSION['user_level'] = $user_level; if($count == 1) { $_SESSION['username']; $_SESSION['password']; header("Location: index.php"); } else { echo "Please check the username and password you entered is correct."; } if($_SESSION['user_level'] == 0) { $_SESSION['username']; $_SESSION['password']; header("Location: index.php"); } else if($_SESSION['user_level'] == -1) { die(); header("Location: banned.php"); } else if($_SESSION['user_level'] < -1) { die(); echo "An error has occurred please contact your administrator."; } else if($_SESSION['user_level'] == 1) { $_SESSION['username']; $_SESSION['password']; header("Location: admin.php"); } } ?> Edited by Tom8001, 23 November 2014 - 12:18 PM. i am trying to add a like system to my forum similar to facebook where it shows how many people like a post. this is my code so far: $like_list = ""; $likes = explode("|", $post_info['post_likes']); $amount_likes = count($likes); $ac_likes = ($amount_likes / 2); $slice = array_slice($likes, 0, 4, true); $remain = array_slice($likes, 4, $ac_likes, true); $remain_num = count($remain); if ($ac_likes >= 4) { for($i=0; $i<$ac_likes; $i+=2) { $like_list .= $likes[$i].", "; } $like_list .= " and $remain_num others like this"; } elseif ($amount_likes == 1 ) { $like_list .= "0 people like this"; } elseif ($ac_likes == 1) { $like_list = implode(", ", $likes); $like_list .= " likes this"; } else { $like_list = implode(", ", $likes); $like_list .= " like this"; } $post_info['post_likes'] contains data like: Code: [Select] user1|123456789|user2|123456789 where the number is the timestamp. unfortunatly $like_list prints the username and the timestamp when i would like it to only display the username. This means printing every 2nd element in the array starting from 0. I have seen this done with for loops but i am not using one therefore i am stuck. Any ideas? and is this the best database setup for likes? the post_likes column is added on to the end of the post table. I am in the process of creating a like system for a personal website that I am working on. I am trying to pull information from one database and use that to place info into another database. When I do I get resource error #15. This is my code that I have so far Code: [Select] function like_add() { $last = $_GET['l']; $first = $_GET['f']; $ip = $_SERVER['REMOTE_ADDR']; $like_sql = "Select * from `counter` where first = ' $first ' and last = '$last '"; $like_result = mysql_query($like_sql); $likes = '<p class="like_button"> Likes '; while ($like_row = mysql_fetch_assoc($like_result)) { $like = $like_row['likes']; $likes .= " $like"; } $likes .= '</p>'; echo "$likes"; echo '<form name="like_add_form" action="" method="POST" class="like_add"> <input type="submit" name="like_add" class="like_add_button" value="Like Me" /> </form>'; if (isset($_POST['like_add'])) { $page_id = "SELECT `page_id` FROM `counter` WHERE first = '$first' AND last = '$last'"; $page_id_result = mysql_query($page_id); echo $page_id_result; <----- Here I am trying to pull information from a field in my database to use as a variable and to place in the second database $voted = mysql_query("Select * FROM `liked_ip` where ip ='$ip' AND page_id='$page_id_result'"); <----- Here I want to use the information from the first table to place in the second one if (mysql_num_rows($voted) != 0) { echo "You have all ready liked this post"; } else { mysql_query("INSERT into `liked_ip`(id,page_id,ip) VALUES ('$page_id_result','$ip')"); } if (mysql_num_rows($voted) == 0) { mysql_query("UPDATE counter SET `likes` = `likes` + 1 where first = '$first' AND last = '$last'"); } } } I know that I have to be doing something so simple that I am just not seeing it this late at night. I may even be completely wrong in all of this. If someone could please help me out I would appreciate it very much. Hi, i have been thinking on ways to make an ordering system for my web site. The code bellow shows how i populate the page. i desplay the pizza's from the data base. i want at the end of each line a box thati allows the user to pick howmany pizzas they want. from they when they click order i want it to send all the information of what they want so they can double check it and when they click the final order button it will send to a diffrent order table. Code: [Select] <? session_start(); if ($_SESSION['userName']) {} else { header('location:../index.php'); } ?> <!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=utf-8" /> <title>Deliver-Pizza Topping</title> <link href="css/pizza-topping.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="container"> <div id="header"> <img src="images/logo.jpg" alt="logo" /> <a href="log-off.php" id="logg-off" >log off</a> <ul id="nav"> <li><a href="home.php" target="_self">Home</a></li> <span> | </span> <li><a href="Pizza-Topping.php" target="_self">Pizza Topping</a></li> <span> | </span> <li><a href="order.php" target="_self">Order</a></li> <span> | </span> <li><a href="Account.php" target="_self">Account Details</a></li> <span> | </span> </ul> </div> <div id="Featured"> <img src="images/banner1.jpg" alt="banner" name="banner"" ID="banner"></div><!--end Featured--> <div class="featuredimage" id="main"> <div id="content" class="tiles"> <h1>Pizza-Topping</h1><hr /> <p>Please select the pizza you would like bellow</p> <div id ="staff"><div style="width:970px; height:300px; overflow:auto" <left> <table> <tr> <th>Type</th> <th>Size</th> <th>Topping</th> <th>Cost</th> <th>Information</th> <th>Order</th> </tr> <tr> <form name="input" action="order.php" method="post"> <?php mysql_connect("localhost", "root", "")or die("cannot connect"); mysql_select_db("deliverpizza")or die("cannot select DB"); $sql="SELECT * FROM `pizzatopping` "; $result= mysql_query($sql); while($row =mysql_fetch_assoc($result)) { ?> <td><?php echo $row['type'] ?></td> <td><?php echo $row['size'] ?></td> <td><?php echo $row['topping'] ?></td> <td><?php echo $row['cost'] ?></td> <td><?php echo $row['info'] ?></td> <td> <input type:"text" name:"pizza<?php echo $row['id'] ?>" /></td> </tr></left> <?php } ?> <input type="submit" value="Order" /> </table> </div> </div> </div> </div> <!--end content--> <div id="footer"><span><p>Created By Ryan Williams</p></span></div><!--end footer--> </div><!--end container--> </body> </html> Help please Hi all I am building a website for a restaurant where the registered user can do booking in the booking page where user finds the booking form. my problem is I created the log in system but cannot workout with the booking page. I have this scenario - Customer visits site & registers details (name, email etc) on a "registration page" (creating a username & password which goes into your database) - done that Next day, customer visits site and logs in on a "log in page" using the username & password from the previous day which is now stored in your database. Can now make a booking based on this log in. (cannot do this) Hello There I've created an Voucher In MySQL/Database system. I would like to know how would I go about programming it into my shopping cart so when a client has an secret Voucher / Coupon they can have a percentage off of the total price of the items their trying to purchase then place thats final price into paypal checkout. shopping cart and database of the Voucher shown below thanks in advance. <?php require "connect_query.php"; $voucher = "CREATE TABLE `voucher_code` ( `id` INT( 11 ) NOT NULL AUTO_INCREMENT , `vouchercode` VARCHAR( 16 ) NOT NULL , `active` TINYINT( 1 ) NOT NULL , `min_basket_cost` FLOAT NOT NULL , `voucher_operation` ENUM( '-', '%', 's' ) NOT NULL , `voucher_amount` FLOAT NOT NULL , `num_vouchers` INT( 11 ) NOT NULL DEFAULT '-1', `expiry` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , PRIMARY KEY ( `ID` )"; if (mysqli_query($db_conx,$voucher)){ echo "Vouchar Table has been CREATED :)"; }else{ echo "Vouchar TABLE was not a success :("; } ?> ////////////////////////////////////// Cart.php <?php // Start session first thing in script session_start(); // Script Error Reporting error_reporting(E_ALL); ini_set('display_errors', '1'); // Connect to the MySQL database include "connect_prompt/connect_query.php"; ?> <?php ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Section 1 (if user attempts to add something to the cart from the product page) ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (isset($_POST['pid'])) { $pid = $_POST['pid']; $size = $_POST['size']; $wasFound = false; $i = 0; // If the cart session variable is not set or cart array is empty if (!isset($_SESSION["cart_array"]) || count($_SESSION["cart_array"]) < 1) { // RUN IF THE CART IS EMPTY OR NOT SET $_SESSION["cart_array"] = array(1 => array("item_id" => $pid, "size" => $size, "quantity" => 1)); } else { // RUN IF THE CART HAS AT LEAST ONE ITEM IN IT foreach ($_SESSION["cart_array"] as $each_item) { $i++; while (list($key, $value) = each($each_item)) { if ($key == "item_id" && $value == $pid){ if ($each_item['size'] == $size){ // That item is in cart already so let's adjust its quantity using array_splice() array_splice($_SESSION["cart_array"], $i-1, 1, array(array("item_id" => $pid, "size" => $size, "quantity" => $each_item['quantity'] + 1))); $wasFound = true; }} // close if condition } // close while loop } // close foreach loop if ($wasFound == false) { array_push($_SESSION["cart_array"], array("item_id" => $pid,"size" => $size, "quantity" => 1)); } } header("location: cart.php"); exit(); } ?> <?php ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Section 2 (if user chooses to empty their shopping cart) ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (isset($_GET['cmd']) && $_GET['cmd'] == "emptycart") { unset($_SESSION["cart_array"]); } ?> <?php ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Section 3 (if user chooses to adjust item quantity) ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (isset($_POST['item_to_adjust']) && $_POST['item_to_adjust'] != "") { // execute some code $item_to_adjust = $_POST['item_to_adjust']; $size = $_POST['size']; $quantity = $_POST['quantity']; $quantity = preg_replace('#[^0-9]#i', '', $quantity); // filter everything but numbers if ($quantity >= 100) { $quantity = 99; } if ($quantity < 1) { $quantity = 1; } if ($quantity == "") { $quantity = 1; } $i = 0; foreach ($_SESSION["cart_array"] as $each_item) { $i++; while (list($key, $value) = each($each_item)) { if ($key == "item_id" && $value == $item_to_adjust) { if ($each_item['size'] == $size ){ // That item is in cart already so let's adjust its quantity using array_splice() array_splice($_SESSION["cart_array"], $i-1, 1, array(array("item_id" => $item_to_adjust, "quantity" => $quantity, "size" => $size))); } // close if condition } // close while loop } // close foreach loop } } ?> <?php ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Section 4 (if user wants to remove an item from cart) ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (isset($_POST['index_to_remove']) && $_POST['index_to_remove'] != "") { // Access the array and run code to remove that array index $key_to_remove = $_POST['index_to_remove']; if (count($_SESSION["cart_array"]) <= 1) { unset($_SESSION["cart_array"]); } else { unset($_SESSION["cart_array"]["$key_to_remove"]); sort($_SESSION["cart_array"]); } } ?> <?php ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Section 5 (render the cart for the user to view on the page) ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $cartOutput = ""; $cartTotal = ""; $pp_checkout_btn = ''; $product_id_array = ''; if (!isset($_SESSION["cart_array"]) || count($_SESSION["cart_array"]) < 1) { $cartOutput = "<h2 align='center'>Your shopping cart is empty</h2>"; } else { // Start PayPal Checkout Button $pp_checkout_btn .= '<form action="[url=https://www.paypal.com/cgi-bin/webscr]https://www.paypal.com/cgi-bin/webscr[/url]" method="post"> <input type="hidden" name="cmd" value="_cart"> <input type="hidden" name="upload" value="1"> <input type="hidden" name="business" value="myemail@gmail.com">'; // Start the For Each loop $i = 0; foreach ($_SESSION["cart_array"] as $each_item) { $item_id = $each_item['item_id']; $sql = "SELECT * FROM products WHERE id='$item_id' LIMIT 1"; $query = mysqli_query ($db_conx,$sql); while ($row = mysqli_fetch_array($query)){ $product_name = $row["product_name"]; $price = $row["price"]; $details = $row["details"]; $taxes = $row["taxes"]; $shipping_one =$row['shipping_one']; } $pricetotal = $price * $each_item['quantity']; $cartTotal = $pricetotal + $shipping_one + $taxes + $cartTotal; setlocale(LC_MONETARY, "en_US"); //$pricetotal = money_format("%10.2n", $pricetotal); // Dynamic Checkout Btn Assembly $x = $i + 1; $pp_checkout_btn .= ' <input type="hidden" name="item_name_' . $x . '" value="' . $product_name . '"> <input type="hidden" name="amount_' . $x . '" value="' . $price . '"> <input type="hidden" name="quantity_' . $x . '" value="' . $each_item['quantity'] . '"> <input type="hidden" name="handling_'. $x . '"value="'. $shipping_one .'"> <input type="hidden" name="tax_'. $x . '"value="'. $taxes .'"> <input type="hidden" name="on0_' . $x . '" value="' . $each_item['size'] . '">'; // Create the product array variable $product_id_array .= "$item_id-".$each_item['quantity'].","; // Dynamic table row assembly $cartOutput .= "<tr>"; $cartOutput .='<td><a href="product.php?id=' . $item_id . '">' . $product_name . '</a><br /><img src="inventory_images/' . $item_id . '.jpg" alt="' . $product_name. '" width="40" height="52" border="1" /></td>'; $cartOutput .= '<td>' . $each_item['size'] .'</td>'; $cartOutput .= '<td>' . $details . '</td>'; $cartOutput .= '<td>$' . $price . '</td>'; $cartOutput .= '<td><form action="cart.php" method="post"> <input name="quantity" type="text" value="' . $each_item['quantity'] . '" size="1" maxlength="2" /> <input name="adjustBtn' . $item_id . '" type="submit" value="change" /> <input name="item_to_adjust" type="hidden" value="' . $item_id . '" /> </form></td>'; //$cartOutput .= '<td>' . $each_item['quantity'] . '</td>'; $cartOutput .= '<td>' . $pricetotal . '</td>'; $cartOutput .= '<td><form action="cart.php" method="post"><input name="deleteBtn' . $item_id . '" type="submit" value="X" /><input name="index_to_remove" type="hidden" value="' . $i . '" /></form></td>'; $cartOutput .= '</tr>'; $i++; } setlocale(LC_MONETARY, "en_US"); // $cartTotal = money_format("%10.2n", $cartTotal); $cartTotal = "<div style='font-size:18px; margin-top:12px;' align='right'>Cart Total : ".$cartTotal." USD</div>"; // Finish the Paypal Checkout Btn $pp_checkout_btn .= '<input type="hidden" name="custom" value="' . $product_id_array . '"> <input type="hidden" name="notify_url" value="[url=https://www.shopstorms.com/storescripts/my_ipn.php]https://www.shopstorms.com/storescripts/my_ipn.php">[/url] <input type="hidden" name="return" value="[url=https://www.mywebsite.com/checkout_complete.php]https://www.mywebsite.com/checkout_complete.php">[/url] <input type="hidden" name="rm" value="2"> <input type="hidden" name="cbt" value="Return to The Store"> <input type="hidden" name="cancel_return" value="[url=https://www.mywebsite.com/paypal_cancel.php]https://www.mywebsite.com/paypal_cancel.php">[/url] <input type="hidden" name="lc" value="US"> <input type="hidden" name="currency_code" value="USD"> <input type="image" src="[url=http://www.paypal.com/en_US/i/btn/x-click-but01.gif]http://www.paypal.com/en_US/i/btn/x-click-but01.gif[/url]" name="submit" alt="Make payments with PayPal - its fast, free and secure!"> </form>'; } ?> <?php if(!empty($pricetotal)) { ?> <?php $discount =""; if($pricetotal >= 50){ echo "FREE SHIPPING!"; } elseif ($pricetotal <= 50){ echo "SPEND MORE THAN 50 GET FREE SHIPPING!"; } ?> <?php } ?> <body> <div align="center" id="mainWrapper"> <div id="pageContent"> <div style="margin:24px; text-align:left;"> <br /> <table width="1024" border="1" cellspacing="0" cellpadding="6" align="center" style="background-color:white;"> <tr> <td width="18%" bgcolor="#C5DFFA"><strong>Product</strong></td> <td align="center" width="10%" bgcolor="#C5DFFA"><strong>Size</strong></td> <td width="45%" bgcolor="#C5DFFA"><strong>Product Description</strong></td> <td width="10%" bgcolor="#C5DFFA"><strong>Unit Price</strong></td> <td width="9%" bgcolor="#C5DFFA"><strong>Quantity</strong></td> <td width="9%" bgcolor="#C5DFFA"><strong>Total</strong></td> <td width="9%" bgcolor="#C5DFFA"><strong>Remove</strong></td> </tr> <?php echo $cartOutput; ?> <!-- <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> --> </table> <table width="1024" border="0" cellspacing="0" cellpadding="0" align="center"> <tr> <th scope="col" align="left"><a href ="cart.php?cmd=emptycart">Click Here to Empty Your Shopping Cart</a></th> <th scope="col" align="center" style="color:black;"> <?php if(!empty ($taxes)) { ?> <?php echo $taxes; ?> <?php } ?> <br/> <?php if(!empty ($shipping_one)) { ?> <?php echo $shipping_one; ?> <?php } ?> <br/> <?php if(!empty ($cartTotal)) { ?> <?php echo $cartTotal; ?> <?php } ?> <br/><?php if(!empty ($discount)) { ?> <?php echo $discount; ?> <?php } ?> <br/> </th> </tr> </table> <table width="1024" height="50" border="0" cellspacing="10" cellpadding="0" align="center"> <tr> <th width="913" align="left" scope="col"></th> <th width="105" align="right" scope="col"><?php echo $pp_checkout_btn; ?> </th> </tr> </table> <br /> <br /> <br /> <br /> </div> <br /> </div> </div> </body> </html> Edited by requinix, 30 June 2014 - 09:15 PM. please use [code] tags when posting code I already have a web based RPG game I am developing. Here is a small video to showcase the loot animation.
My problem is, I want to add combat. I will be using html 5 websockets. I already have a websockets server up so multiplayer isn't the issue.
A good combat system I found is on this game:
http://treasurearena.clay.io/
I'm not going to dig out the source code, and try to extract the combat system from this game. Just trying to find something similar that I can use, does anyone have any recommendations?
Thanks!
Edit: It can be as simple as swinging a freaking sword and moving. That's all I really want, I just don't want the boring 'click', 'click', and 'click' bullshit.
Looking for the best way to set-up the db of a messaging system. Here's what I have so far (basically pulled from another forum), don't know if Table1 is even really necessary: Table1: id user_message_id recepient_id recepient_read Table2: user_message_id sender_id sender_read subject message created_at updated_at Basically it needs to function where, someone submits a message to the admin or moderator, the admin/moderators can review and reply, and then the user can submit another reply, and keeps going indefinitely. I want each reply to show up almost like a forum thread. How would I chain the reply messages to the original messages? I'm busy with a small storage system for my site, but i encounter some problems with it. I have successfully managed to get all products from the order, and traced on what spots those product are in the warehouse. It looks like this atm http://img37.imageshack.us/img37/7302/tableordereng.jpg this is the code i have atm (sorry i program in dutch, i hope its abit understandable) Code: [Select] <?php $query = "select * from `orderregel` WHERE `ordernr`='".$ordernr."'"; $row = mysql_fetch_array( $query ); echo "<table border=1 width=680 bgcolor=#FFFFFF> <tr> <th width= 100>artikelnummer</th> <th width= 100>productnaam</th> <th width= 40>Plaats</th> <th width= 40>aantal in magazijn</th> <th width= 40>aantal nodig</th> </tr> </table>"; foreach ( self::find_by_sql($query) as $user) { $query2 = "select * from magazijn WHERE artikelnr = ".$user->artikelnr.""; $row = mysql_fetch_array( $query ); foreach ( self::find_by_sql($query2) as $magazijn) { echo "<table class= order_overzicht border= 0 width= 680>"; echo "<tr> <td width= 100>".$magazijn->artikelnr."</td> <td width= 100>".$magazijn->productnaam."</td> <td width= 40>".$magazijn->magazijn_plaats."</td> <td width= 40>".$magazijn->aantal."</td> <td width= 40>".$user->aantal."</td> </tr> </table>"; } } ?> The problem i have now is, that i want it to do the following. for example someone orders 430 packages of Haribo Kers Cola (see imageshack upload). I first want it to empty spot 16 in the wherehouse. Only when spot 16 is empty, i want it to go to the next spot (19) wich contains the same product. the end result would be something like this: http://img690.imageshack.us/img690/6246/tableorderneweng.jpg i hope you guys can help me out on this one, becouse i have no clue how i can resolve this problem thanks in advance (Sorry btw for my bad english ) im working on a point system for my forum where points are awarded based on actions taken. $scores = array( 'login' => 1, 'editor' => 10 ); so if a user logs in then they will be awarded 1 point, if they edit their post then they get 10 points etc. So in my login process page i process the login then award the points that it is worth with $score['login']. Everything works fine. My problem is that this is a forum package like phpbb and mybb where people download the package and can install their own forum. So i want them to be able to add to the points list. For example the admin chooses to award 10 points for every post that is made. how would i go about implementing this? the points categories would be in the database but what happens in the post processing page when i add the post to the database? how would i know that the admin wants some points awarded? the database would look like so: id title points 1 post 10 but the title can change based on the admins choosing of words. I hope i explained this ok. Hi there, I am a student from the UK and I am taking PHP and mySql programming for the first time. I have done a bit of python and html before. I do have some experience with PHP though.
I need to create a project for my coursework. My system will be an MVP system (Cricket) where scores will be input and then MVP scores obtained. I wanted to know if anyone has any experience with this and thus could helpfully guide me in the right direction with resources and anything that could be deemed relevant.
I am more than happy to explain further and send my prototype over. Many thanks. Hi guys, im making a basic social networking site for a college project and I need to know how to make a system that will let logged in users add each other as friends but I carnt really find anything on google about how to start. Can anyone here help me or know a tutorial I can follow that will let me create something like this? Thanks |