PHP - How Do I Carry $from Over?
Heres my code:
<?php include_once("db_connect.php"); if(isset($_COOKIE['user'])) { //get who to steal from $from = mysql_real_escape_string($_GET['from']); //check if they selected someone if(!$from) { echo "You haven't selected a user to steal from!"; } else { if(!$_POST['amount']) { echo "Amount to steal from ". $from .": <form action='steal.php' method='POST'> <input type='text' name='amount'><input type='submit' value='Steal'></form>"; } else { //grab the other users money $grab_other = mysql_query("SELECT money FROM users WHERE username = '$from'"); //extract $extract = mysql_fetch_assoc($grab_other); //check if the user is valid if(mysql_num_rows($grab_other) == 0) { } elseif($extract['money'] == $_POST['amount']) { $one = rand(1, $_POST['amount']); $two = rand(1, $_POST['amount']); //if they successfully stole if($one == $two) { echo "You've successfully stole from ". $from ."! $". $_POST['amount'] ." has been added to your account!"; } } else { echo "They don't have enough money!"; } } } } else { echo "You must be logged in before you can do this! <a href='index.php'>Home</a>"; } ?> $from (which is a GET) is who the user wish to steal from. How do I carry that over? If they go he http://composedscripts.zxq.net/money_game/steal.php?from=Justin - And they enter in an amount, it will forget $from and say they haven't entered in a user to steal from. How do I stop this from happening? Similar TutorialsHello, I've been racking my brains (and spending sleepless nights) trying to get a login system to work by where the member will insert their email address as [username] and password (already stored in the DB) - then the page to divert to an administration panel with their User_id for them to only edit their information. The Code I have so far..... The login_form.php Code: [Select] <?php //Start session session_start(); //Unset the variables stored in session unset($_SESSION['SESS_CLIENT_EMAIL']); unset($_SESSION['SESS_MAIN_ID']); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Client Admin Panel</title> <link href="style.css" rel="stylesheet" type="text/css" media="screen" /> </head> <body> <div id="wrapper"> <div id="header"> <h1>CLIENT LOGIN</h1> <h2>CLIENT ADMINISTRATION PANEL</h2> version 2.10 </div> <div id="menu"> </div> <div id="content"> <div id="right"> <div class="post"> <h2>CLIENT ADMINISTRATION PANEL - CLIENT LOGIN</h2><br /> <h3><span class="err"><strong><font color="#800000">PLEASE LOGIN</font></strong></span></h3><form id="loginForm" name="loginForm" method="post" action="login-exec.php"> <table width="315" border="0" align="center" cellpadding="2" cellspacing="0"> <tr> <td width="150"><b>Email Address:</b></td> <td width="157"><input name="login" type="text" class="textfield" id="client_email" /></td> </tr> <tr> <td><b>Secret Word:</b></td> <td><input name="password" type="password" class="textfield" id="client_password" /></td> </tr> <tr bgcolor='#f1f1f1'> <td> </td> <td><input type="submit" name="Submit" value="Login" /></td> </tr> <tr> <td colspan="2"><hr /></td> </tr> <tr> <td><b>Forgot SecretWord?:</b></td> <td><font face='tahoma, arial, helvetica' size='2' ><a href='forgot-password.php'>Click Here</a></font></td> </tr> <tr> <td colspan="2"><hr /></td> </tr> <tr> <td><b>New Client?:</b></td> <td><font face='tahoma, arial, helvetica' size='2' ><a href='../dhsite/webpages/reg_1.php'> Register Here</a></font></td> </tr> </table> <br /> </form></p> </div> </div> </div> <div id="footer"> <p class="copyright">Copyright © *****************</p> </div> </div> </body> </html> And the handler: login_exec.php Code: [Select] <?php //Start session session_start(); $_SESSION['var'] = $val; //Include database connection details require_once('config.php'); //Array to store validation errors $errmsg_arr = array(); //Validation error flag $errflag = false; //Connect to mysql server $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } //Select database $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } //Function to sanitize values received from the form. Prevents SQL injection function clean($str) { $str = @trim($str); if(get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } //Sanitize the POST values $client_email = clean($_POST['login']); $client_password = clean($_POST['password']); //Input Validations if($client_email == '') { $errmsg_arr[] = 'Email Address missing'; $errflag = true; } if($client_password == '') { $errmsg_arr[] = 'Password missing'; $errflag = true; } //If there are input validations, redirect back to the login form if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; session_write_close(); header("location: login-form.php"); exit(); } //Create query $qry="SELECT client_email, client_password, main_id FROM users WHERE client_email='$client_email' AND client_password='$client_password'"; $result=mysql_query($qry); //Check whether the query was successful or not if($result) { if(mysql_num_rows($result) == 1) { //Login Successful session_regenerate_id(); $member = mysql_fetch_assoc($result); $_SESSION['SESS_CLIENT_EMAIL'] = $member['client_email']; $_SESSION['SESS_MAIN_ID'] = $member['main_id']; session_write_close(); header("Location: test_admin_panel.php?user_id=".$main_id.""); exit(); }else { //Login failed header("location: login-failed.php"); exit(); } }else { die("Query failed"); } ?> Any help would be VERY much appreciated!! Hi,
I have a page that carries through cookies and displays a different image/banner depending on the cookies. The URLs look something like: http://www.website.c...gent=agent-name
I now have a page with an iFrame on displaying the URL: http://www.website.c...gent=agent-name
If I access http://www.website.c...gent=agent-name normally, they cookies carry through and the banner shows, but it doesn't if I access it through the iFrame.
Is there a way of carrying the cookies into the iFrame?
Also the URL that the iFrame is on is different to the content of the page inside the iFrame.
Thanks!
|