PHP - Passing Value Of Variable From One Php File To Another Using $_post
Hi, I need to pass value of variable to another php file. I thought it is possible to do it as following:
<form action="products.php"> <INPUT TYPE=hidden NAME='id' . VALUE='$id'> </form> But the problem is like that. The php file inside which I want to write above html code has not using <form> tag and it has no buttons. So how to initiate the transfer of variable into another php file? Is the above idea is not the good idea? Are there any another ways? Similar TutorialsHi Guys, I'm working on an image resizer, to create thumbnails for my page. The resizer works on principle of include a DIRECT link to the image. But what I want to do is put in the PHP Variable in the URL string, so that it points to that file and resizes it accordingly. My code is as follows : Code: [Select] <img src="thumbnail.php?image=<?php echo $row_select_property['image_url']; ?> Image Resize : Code: [Select] <?php // Resize Image To A Thumbnail // The file you are resizing $image = '$_GET[image_url]'; //This will set our output to 45% of the original size $size = 0.45; // This sets it to a .jpg, but you can change this to png or gif header('Content-type: image/jpeg'); // Setting the resize parameters list($width, $height) = getimagesize($image); $modwidth = $width * $size; $modheight = $height * $size; // Creating the Canvas $tn= imagecreatetruecolor($modwidth, $modheight); $source = imagecreatefromjpeg($image); // Resizing our image to fit the canvas imagecopyresized($tn, $source, 0, 0, 0, 0, $modwidth, $modheight, $width, $height); // Outputs a jpg image, you could change this to gif or png if needed imagejpeg($tn); ?> What I am trying to do is pass on the variable "image=<?php echo $row_select_property['image_url']; ?>" to the Thumbnail script. At the moment I am passing it through the URL string, but it doesnt seem to load the graphic. I'll try expand on this more, should you have questions as I am finding it a little difficult to explain. Thanks in advance. Hi all, I have my whole script working only the name of the upload file won't pass to the process.php page. Any help much appreciated. Prob just some silly mistake that i made but i can't for the life of me see it. form Code: [Select] <form enctype="multipart/form-data" action="process.php" method="POST" name="books" title="Santa_Book"> <img src="images/book/Enter_your_details.png" width="400" height="60" /><br /> <ul id="inline_list"> <input type="text" name="first_name" id="first_name" value="Text to be displayed here" onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;"/> <label for="sur_name" class="inside">Name</label> <input name="sur_name" type="text" id="sur_name" class="inside" /> <label for="sname">Surname</label> <br /> Sex <select name="sex" id="sex"> <option selected="selected">Please Select....</option> <option value="girl">Girl</option> <option value="boy">Boy</option> </select> <label for="age">Age</label> <input type="text" name="age" id="age" /> <br /> <label for="house_no">House No.</label> <input type="text" name="house_no" id="house_no" /> <br /> <label for="street">Street Name</label> <input type="text" name="street" id="street" /> <br /> <label for="town">Town</label> <input type="text" name="town" id="town" /> <br /> <br /> <select name="bscf1" id="bscf1"> <option selected="selected">Please Select...</option> <option value="Brother1">Brother</option> <option value="Sister1">Sister</option> <option value="Cousin1">Cousin</option> <option value="Friend1">Friend</option> </select> <label for="bscf_name1">Friend / Sibling</label> <input type="text" name="bscf_name1" id="bscf_name1" /> <br /> <select name="bscf2" id="bscf2"> <option>Please Select...</option> <option value="Brother2">Brother</option> <option value="Sister2">Sister</option> <option value="Cousin2">Cousin</option> <option value="Friend2">Friend</option> </select> <label for="bscf_name2">Friend / Sibling</label> <input type="text" name="bscf_name2" id="bscf_name2" /> <br /> <label for="from_name">This book is from...</label> <input type="text" name="from_name" id="from_name" /> <br /> <input name="uploadedfile" type="file" id="uploadedfile" value="Upload Image" /> <br /> </ul> <br /> <input type="submit" value="Continue" /> </form> process.php page Code: [Select] <?php // Database connect $con = mysql_connect("mysql1.myhost.ie","admin_book","root123"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("book_test", $con); //Parse Values from Coupon.php Form $first_name = mysql_real_escape_string(trim($_POST['first_name'])); $sur_name = mysql_real_escape_string(trim($_POST['sur_name'])); $sex = mysql_real_escape_string(trim($_POST['sex'])); $age = mysql_real_escape_string(trim($_POST['age'])); $house_no = mysql_real_escape_string(trim($_POST['house_no'])); $street = mysql_real_escape_string(trim($_POST['street'])); $town = mysql_real_escape_string(trim($_POST['town'])); $bscf1 = mysql_real_escape_string(trim($_POST['bscf1'])); $bscf_name1 = mysql_real_escape_string(trim($_POST['bscf_name1'])); $bscf2 = mysql_real_escape_string(trim($_POST['bscf2'])); $bscf_name2 = mysql_real_escape_string(trim($_POST['bscf_name2'])); $from_name = mysql_real_escape_string(trim($_POST['from_name'])); $uploadedfile = mysql_real_escape_string(trim($_POST['name'])); if ($sex == 'girl') { $his_her = 'her'; } else { $his_her = 'his'; } if ($sex == 'girl') { $him_her = 'her'; } else { $him_her = 'his'; } $sql="INSERT INTO details (first_name, sur_name, sex, age, house_no, street, town, bscf1, bscf_name1, andy, bscf2, bscf_name2, his_her, him_her, from_name, uploadedfile) VALUES ('$first_name','$sur_name','$sex','$age','$house_no','$street','$town','$bscf1','$bscf_name1','and','$bscf2','$bscf_name2','$his_her','$him_her','$from_name','$uploadedfile')"; // Where the file is going to be placed $target_path = "uploads/"; /* Add the original filename to our target path. Result is "uploads/filename.extension" */ $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); $target_path = "uploads/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } echo 'Thank you '. $first_name . ' for entering your details bro.<br />'; echo 'surname is : '. $sur_name . '.<br />'; echo 'sex is : '. $sex . '.<br />'; echo 'age is: '. $age . ' .<br />'; echo 'bscf friend 1 is : '. $bscf1 . '.<br />'; echo 'bscf name 1 is : '. $bscf_name1 . '.<br />'; echo 'bscf friend 2 is : '. $bscf2 . '.<br />'; echo 'bscf name 2 is : '. $bscf_name2 . '.<br />'; echo 'his_her is : '. $his_her . ' .<br />'; echo 'him_her is : '. $him_her . '.<br />'; echo 'From Name is : '. $from_name . '.<br />'; echo 'Uploaded file is : '. $uploadedfile . '.<br />'; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } ?> This is what I have for code: Code: [Select] <?php $title="Login"; $metakeywords="login, email"; $metadescription="Login to Dating Snap!"; include('header.php'); $user = clean_up($_POST['email']); $pass = clean_up($_POST['password']); if($user && $pass) { $pass = md5($pass); //compare the encrypted password $sql="SELECT id,email,type,password,activation_key FROM `users` WHERE `email`='$user' AND `password`='$pass'"; $query=mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($query) > 0) { $lllrow = mysql_fetch_assoc($query); if($lllrow['activation_key'] == 0){ $_SESSION['id'] = $lllrow['id']; $_SESSION['type'] = $lllrow['type']; $_SESSION['email'] = $lllrow['email']; $_SESSION['password'] = $lllrow['password']; $date=date("M d Y"); $time=date("g:i A"); $sql3 ="UPDATE `users` SET `last_ip`='{$_SERVER['REMOTE_ADDR']}', `last_login`='$date $time' WHERE `id`='".$_SESSION['id']."'"; $res3 = mysql_query($sql3) or die(mysql_error()); }else{ echo "<div class='error'>You need to activate your account first!</div>"; } echo '<meta http-equiv="REFRESH" content="0;url=index.php">'; } else { echo "<div class='error'>Email and password combination is incorrect!</div>"; } }else{ if(!$_GET['step'] && $_POST['newpassword']){ $email = clean_up($_POST['email']); $password = clean_up($_POST['newpassword']); $sql = "SELECT * FROM `users` WHERE `email`='$email'"; $query = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($query) > 0) { echo "That email is already being used, please try another."; }else{ $activation_number = rand( ); $subject = 'Activate your account on datingsnap.com'; $message = 'Dear '.$first.' '.$last.',<br>Thank you for registering for an account on Dating Snap. Please <a href="http://datingsnap.com/index.php?action=activate&id='.$activation_number.'">Click Here</a> to activate your new account.<br>All the best,<br> DatingSnap.com'; $headers = 'From: bobthewebbuilder@gmail.com' . "\r\n" . 'Content-Type: text/html; charset=\"iso-8859-1\"' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $sql = "INSERT into `users`(`activation_key`,`password`,`email`) VALUES ('$activation_number','".md5($password)."','$email');"; $query = mysql_query($sql) or die(mysql_error()); echo '<form method="post" action="index.php?action=login&step=1"><table width="100%"> <input id="email" type="hidden" name="email" value="$email"> <table width="100%"> <tr> <td class="content">*<b>First Name:</b></td> <td class="content"><input class="tarea" id="first" size="30" type="text" name="first"></td> </tr> <tr> <td class="content">*<b>Last Name:</b></td> <td class="content"><input class="tarea" id="last" size="30" type="text" name="last"></td> </tr> <tr><td width="150" class="content"></td><td class="content"><input type="submit" name="submit" value="Next step"></td></tr></form></table>'; } if($_GET['step'] == "1" && $_POST['email']){ $email = clean_up($_POST['email']); $first = clean_up($_POST['first']); $last = clean_up($_POST['last']); $sql = "UPDATE `users` SET `first`='$first',`last`='$last' WHERE `email`='$email'"; $query = mysql_query($sql) or die(mysql_error()); echo '<table width="100%"><form method="post" action="index.php?action=login&step=2"> <input id="email" type="hidden" name="email" value="$email"> <tr> <td class="content">*<b>Date of birth:</b><br><small>This will be used to calculate your age so be sure to use your correct birth date</small></td><td class="content"> <select name="month" id="month"> <option value="1">January</option> <option value="2">February</option> <option value="3">March</option> <option value="4">April</option> <option value="5">May</option> <option value="6">June</option> <option value="7">July</option> <option value="8">August</option> <option value="9">September</option> <option value="10">October</option> <option value="11">November</option> <option value="12">December</option> </select> <select name="day" id="day"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> <select name="year" id="year">'; $start_year = ($start_year) ? $start_year - 1 : date('Y') - 110; $end_year = ($end_year) ? $end_year : date('Y'); for ($i = $end_year; $i > $start_year; $i -= 1) { echo '<option value="'.$i.'">'.$i.'</option>'; } echo '</select> </td> </tr><tr><td width="150" class="content"></td><td class="content"><input type="submit" name="submit" value="Next step"></td></tr></form></table>'; } if($_GET['step'] == "2" && $_POST['email']){ $email = clean_up($_POST['email']); $month=clean_up($_POST['month']); $day=clean_up($_POST['day']); $year=clean_up($_POST['year']); $sql = "UPDATE `users` SET `bdate`='$year-$month-$day' WHERE `email`='$email'"; $query = mysql_query($sql) or die(mysql_error()); echo "Done step two!"; } } //end if email } include('footer.php'); ?> How come $_POST['email'] isn't getting passed down the steps? I have a hidden field that holds it in each step... what am I overlooking? ok so here the deal. i have to write a script that searches a giant database of school and returns the contact info for all schools matching the search term. no big deal it's cake to code something that simple... but wait there more! the search must be executed by a joomla page... we crap. joomla doesn't allow me to run php scripts... so i found a little plugin called jumi that lets me do just that. and it works great minus all the errors joomla spits out because the mysql_connect statement and the mysql_query statment are connecting to a different database than the one joomla is installed onand thus joomla thinks the tables i am searching don't exist so joomla outputs this 4 page long error code in a bright red box a the top of the page. so i tried turning off joomls error reporting.. no bueno. so i figured no problemo i'll just have the script call out to a .php file hosted else where on the server and pass the search terms to that file via $_POST. then have said file execute a quick search of the database and return the results back to the original joomla page from whence the search commenced via a nice tidy $_POST array. one problem how in hades do you pass around php arrays via $_POST? I'm practicing my OOP skills and want to pass $_POST values to an Object's Instance Variables when a form is submitted. This is what I have so far... index.php Code: [Select] <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> </head> <body> <!-- Registration Form --> <form method="post" action="results.php"> <!-- Registration Fields --> <div> <label for="email">E-mail:</label> <input type="text" name="email" class="txt" id="email" /> </div> <div> <label for="password">Password:</label> <input type="password" name="password" class="txt" id="password" /> </div> <div> <input type="submit" name="btnSubmit" value="Register" class="btn" id="btnSubmit" /> </div> </form> </body> </html> results.php Code: [Select] <?php include ('classes/FormHandler.class.php'); ?> FormHandler.class.php Code: [Select] <?php class HandleForm { // Define Variables. private $email; private $password; public function __construct($email, $password){ $this->email = $email; $this->password = $password; } } ?> I'm a little stuck on how I initialize the Instance Variables in the Constructor?! TomTees I've been poking around the Internet for the answer to this without any success. This query APPEARS to run, but NOTHING GETS INSERTED. The QuestionID in the Questions table is set to auto-increment, so I only need the QuestionText data for this table. the QuestionID in the Answers table is not because there might be four or five options per question. The snippets of code under consideration is pasted below snipped from index.php: Code: [Select] <form action="./newquestion.php" method="post"> Question Text:<br><input type="text" size=100 name="QuestionText" /><br><br> <input type="submit" value="Enter next question"/> </form> Then snipped from newquestion.php mysql_select_db(quiz); $query = mysql_query("INSERT INTO Questions VALUES ('$_POST[QuestionText]'"); $result = mysql_query($query); Thank you all. I'm sure I'll learn this pretty fast, but I still need a little help. I have a form that creates rows of data input textboxes depending on a user input number of things. I have a naming convention for all these textboxes that basically just keeps incrementing a number suffix for each row. All this is working fine. My problem is I need to get the data inserted into this table of textboxes into an array. Here's my code where I attempt to to this (it does not work): Code: [Select] $temp = $_SESSION['Num_Part']; $count = 1; while ($count <= $temp){ $temp2[$count] = "'Participant_P".$count."'"; //echo $temp2[$count]."<br/>"; $temp3[$count]=$_POST[$temp2[$count]]; //here's the problem $temp4[$count] = "'Result_P".$count."'"; $temp5[$count]=$_POST[$temp4[$count]]; //here's the problem //echo $temp4[$count]."<br/>"; $count++; } The problem is that the $_POST does not work with the variable in the argument position - even though the argument is formatted with single quotes. Can a variable be used in a POST argument and if so what is the correct syntax? If not, is there some other simple solution to harvest the data into an array. I understand I can harvest by explicitly accessing each key in the post assoc array. But this could be dozens of rows of input fields. Thanks in advance for your help here. I couldn't find anything online re this topic. Code: [Select] $amountBoxName = "amount".$id; // Constructs the name of the input field $amountToPay = strip_tags($_POST["$amountBoxName"]); $amountBoxName then goes to 'amount22' says, however $amountToPay is then showing also as 'amount22', not getting the value of the text field whose name/id is amount22 on the previous page. How do I do this? I tried having " around the $amountBoxName, ' and no quotes although still can't get it working. Why doesn't this code work... Code: [Select] // Initialize variables. $form_value = ''; $form_value = $_POST['form_value']; I get this error... Quote Notice: Undefined index: form_value Thanks, Debbie Hi Everyone, I'm trying to make an userlist where I have a button (or better a picture with a hyperlink) which if I click it I will be forwarded to a new page where the user name is send as a $_Post variable. The code below is what I have this far. In some way when I click the send button it always gives the last username in the table in the $_Post variable. Can anyone help me please. Thnx Ryflex <?php require_once('auth.php'); require_once('config.php'); $global_dbh = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die("Could not connect to database"); mysql_select_db(DB_DATABASE, $global_dbh) or die("Could not select database"); $user_query = "SELECT * FROM members"; $user_result = mysql_query($user_query); ?> <form ID="gotoresource" NAME="gotoresource" METHOD="POST" ACTION="resource_compose.php"> <table width="500" border="1" align="center" cellpadding="2" cellspacing="0"> <tr> <td><b>User</b></td> <td><b>Resource</b></td> </tr> <?php while($row = mysql_fetch_assoc($user_result)) { echo "<tr>"; echo "<td>"; echo $row['login']; $user = $row['login']; ?> <input name="User" type="hidden" maxlength="15" id="user" value="<?php echo $user; ?>"/> </td> <td> <input type="submit" name="Submit" value="Send" /> </td> <?php echo "</tr>"; } ?> <html> <head> <title>Userlist</title> <link href="loginmodule.css" rel="stylesheet" type="text/css" /> </head> <body> </body> </html> what would be the $_POST variable name for a radio button option? User clicks on a url, ie: example.com/AEQ438J When I perform this in the code below: Code: [Select] $referrer = $_GET['_url']; // echo $referrer displays the referrer ID contents correctly as "AEQ438J" if ( ! empty($referrer)) { $mysqli->query("UPDATE coming_soon_emails SET clicks = clicks + 1 WHERE code='" . $referrer ."'"); } // this also updates the database correctly as it should if (!empty($_POST['email'])){ // echo $referrer displays the referrer ID contents as BLANK. It should display "AEQ438J"! ..... $referrer displays correctly BEFORE if($_POST['form']), however during the if($_POST['form']) $referrer is empty. How can I fix my code so that $referrer is not empty during the time the user posts their email address in the form? Thank you! Complete PHP and HTML Code: [Select] <?php require "includes/connect.php"; //var_dump($_GET);die; function gen_code($codeLen = 7) { $code = ''; for ($i=0; $i<$codeLen; $i++) { $d=rand(1,30)%2; $code .= $d ? chr(rand(65,90)) : chr(rand(48,57)); } return $code; } function add_code($email_id) { global $mysqli; $code = gen_code(7); $mysqli->query("UPDATE coming_soon_emails SET code='" . $code ."' WHERE email_id='" . $email_id . "'"); if($mysqli->affected_rows != 1) { add_code($email_id); } else return $code; } $msg = ''; $referrer = $_GET['_url']; // echo $referrer displays the referrer ID contents correctly if ( ! empty($referrer)) { $mysqli->query("UPDATE coming_soon_emails SET clicks = clicks + 1 WHERE code='" . $referrer ."'"); } if (!empty($_POST['email'])){ // echo $referrer displays the referrer ID contents as BLANK // Requested with AJAX: $ajax = ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'); try{ if(!filter_input(INPUT_POST,'email',FILTER_VALIDATE_EMAIL)){ throw new Exception('Invalid Email!'); } $mysqli->query("INSERT INTO coming_soon_emails SET email='".$mysqli->real_escape_string($_POST['email'])."'"); if($mysqli->affected_rows != 1){ throw new Exception('This email already exists in the database.'); } else { $email_code = add_code($mysqli->insert_id); } $msg = "http://www.example.com/" . $email_code; //the following doesn't work as referrer is now empty :( if ( ! empty($referrer)) { $mysqli->query("UPDATE coming_soon_emails SET signup = signup + 1 WHERE code='" . $referrer ."'"); } if($ajax){ die(json_encode(array('msg' => $msg))); } } catch (Exception $e){ if($ajax){ die(json_encode(array('error'=>$e->getMessage()))); } $msg = $e->getMessage(); } } ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <link rel="stylesheet" type="text/css" href="css/styles.css" /> </head> <body> <div id="launch"> <form id="form" method="post" action=""> <input type="text" id="email" name="email" value="<?php echo $msg;?>" /> <input type="submit" value="Submit" id="submitButton" /> </form> <div id="invite"> <p style="margin-top:20px;">The ID of who referred you: <?php echo $referrer; //this displays correctly?>)</p> <p style="margin-top:20px;"><span id="code" style="font-weight:bold;"> </span></p> </div> </div> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script> <script src="js/script.js"></script> </body> </html> script.js Code: [Select] $(document).ready(function(){ // Binding event listeners for the form on document ready $('#email').defaultText('Your Email Address'); // 'working' prevents multiple submissions var working = false; $('#form').submit(function(){ if(working){ return false; } working = true; $.post("./index.php",{email:$('#email').val()},function(r){ if(r.error){ $('#email').val(r.error); } else { $('#email').val(r.msg); // not needed but gets hidden anyways... $('#launch form').hide(); $("#code").html(r.msg); $("#invite").fadeIn('slow'); } working = false; },'json'); return false; }); }); // A custom jQuery method for placeholder text: $.fn.defaultText = function(value){ var element = this.eq(0); element.data('defaultText',value); element.focus(function(){ if(element.val() == value){ element.val('').removeClass('defaultText'); } }).blur(function(){ if(element.val() == '' || element.val() == value){ element.addClass('defaultText').val(value); } }); return element.blur(); } htaccess Code: [Select] RewriteEngine on RewriteCond %{HTTP_HOST} ^my-url.com RewriteRule (.*) http://www.my-url.com/$1 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([a-z0-9]+)$ /index.php?_url=$1 [NC,L,QSA] table.sql Code: [Select] CREATE TABLE IF NOT EXISTS `coming_soon_emails` ( `email_id` int(11) NOT NULL auto_increment, `email` varchar(64) collate utf8_unicode_ci NOT NULL, `code` char(7) collate utf8_unicode_ci DEFAULT NULL, `clicks` int(64) collate utf8_unicode_ci DEFAULT 0, `signup` int(64) collate utf8_unicode_ci DEFAULT 0, `ts` timestamp NOT NULL default CURRENT_TIMESTAMP, PRIMARY KEY (`email_id`), UNIQUE KEY `email` (`email`), UNIQUE KEY `code` (`code`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; I have tilbud.php file that has no output. Just receives data and adds them into MySQL table. Inside tilbud.php file I have JavaScript code that calls products.php. Product.php has the following code: if(!isset($_POST['userid'])) { echo "<script type='text/javascript'>"; echo "window.location = 'index.php'"; echo "</script>"; exit; } So, I you call product.php without submitting $_POST['userid'] it redirects you into index.php. How to submit $_POST['userid'] into products php without using <form method='POST' action='product.php'> ? Hi all, I've done a LOT of googling on this and found things that match what I need but nothing actual achieves what I need. I've used one php file before for doing multiple jobs (ie registration?step=2 / 3 etc), but I've boo-booed somewhere and it only works up until step 2, step 3 doesn't work. Here's what I have currently, it also leads me on to the next question. Code: [Select] <?php if(isset($_GET['step']) == 2) { ?> Please select the problem you are encountering. <a href="registration.php?step=3&console=<?php $_GET['console'] ?>&issue=1rrod"><img src="store/image/data/1rrod.gif" width="92" height="92" /></a> <?php } if (isset($_GET['step']) == 3) { ?> END <?php } else {?> Please select which type of Xbox 360 you have<br /> <a href="registration.php?step=2&console=xbox"><img src="images/xbox360.gif"></a> <a href="registration.php?step=2&console=xboxslim"><img src="images/xbox360e.gif"></a> <?php } ?> So, first step (which is bottom), lets you select which type of console it is - only two possible choices. That then passes that data to step 2, which is what issue the console is having. Now I've tried this with $_POST, as I would prefer to work that way. I've experimented with $_SESSION to try and pass everything I need, using code found elsewhere. But I just can't get it to pass from page to page and finally be able to use it to email in the final step. Final issue - I want to use images instead of buttons to be able to pass the variables. I've found that using hidden type input does work but I think this issue is related to the above one. Thanks! Jason Hi, can anybody please tell me how i can make "Arson" into a php variable Code: [Select] <script type="text/javascript" src="js/swfobject.js"></script> <script type="text/javascript"> swfobject.embedSWF( "open-flash-chart.swf", "my_chart", "550", "400", "9.0.0", "expressInstall.swf", {"data-file":"ofc-chart.php?crime=Arson"} ); </script> I had an iframe working for the last few months on a site at hostgator. Yesterday, it quit working (403 permissions error). After a long bout of trouble-shooting, I found out that it has something to do with mod_security that they have suddenly enabled (have no idea as I'm not a Linux guy). They told me they fixed the problem on my domain by whitelisting it as an exception, but strangely, even though the permissions error went away, the actual src= box of the iframe, which was the url variable I was passing in the url, no longer loads. So.. I'm trying to break this down into the simplest form to figure it out. I just understand php basics so needing some verification that I'm doing this right/wrong. Here's my code.. page1.php Code: [Select] <? $testurl = "http://google.com"; ?> <a href="http://mysite.blah/page2.php?url=<? echo $testurl; ?>">page2.php</a> page2.php Code: [Select] if (isset($_GET['testurl'])) echo $testurl; else echo "sorry dude"; I am only able to print "sorry dude". Am I doing something wrong or shouldn't this send the url? Thanks for the help! I'm an hour worth of searches into this. It's 2:30. I just want some nice person to give me the answer. I'm trying to pass a variable using href to another page. It works great if the variable is only one word. But it only passes the first word. There are multiple posts on this topic, but I can't seem to get any of those fixes to work for me. Here the code. Code: [Select] <?php $query = "select DISTINCT city from daily where open_bid>0 order by city ASC"; $result = mysql_query($query); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $details=''; $details.='<li class="menu"><span class="name"><a href=list.php?city='.$row['city'].'>'.$row['city'].'</a>'; $details.='</li>'; echo($details); } ?> As you can imagine, some cities names are made up of two words. This is only passing the first word. Thanks for your help. This is driving me MAD! The Variable gets passed through the URL but when I try and echo the result I gte NOTHING. First Page. Code: [Select] <?php include'config.php'; $result = mysql_query("SELECT * FROM carbontrust"); while($entry = mysql_fetch_array($result)) Print "$entry[contact] - $entry[company] :: <a href='edit.php?id=$entry[id]'>Edit</a><br>"; exit; ?> Second Page. (Where I want the Variable passed to) Code: [Select] <?php include'config.php'; $id = $_GET['id']; echo "ID: $id"; } ?> Its probably just a stupid error but iv looked through a load of tutorials and this should be correct. :/ Trying to set up an error message when someone tries to upload a file without the approved .ext. I have it working so it won't up load but I am trying to get an error to print out. I was thinking that I could do something like this if the ext are wrong set $errorMsg1 == 1; and then the page will refresh and I would pass that variable to echo out if ($errorMsg1 == 1){ echo "Invalid"; } else { but it isn't passing can anyone help me with this? Tyring to keep it simple this is the code to select an image else{ $result = mysql_query("SELECT * FROM photos WHERE userID LIKE '$clientID'"); while ($r=mysql_fetch_array($result)) { $photo_1=$r['photo_1']; $photo_2=$r['photo_2']; $photo_3=$r['photo_3']; $photo_4=$r['photo_4']; $photo_5=$r['photo_5']; echo " <form enctype='multipart/form-data' action='' method='POST'> <input type='hidden' name='MAX_FILE_SIZE' value='500000' /> <div id='imageTop'>Image &#35;1</div> "; if ($errorMsg1 == 1){ echo "Invalid"; } echo " <div id='imageBottom'> <span class='image'>"; if (empty($photo_1)) { echo " <img src='uploads/noPhoto.gif' width='75' height='75' class='zip'> "; } else { echo "<a href='uploads/$photo_1' ><img src='uploads/$photo_1' width='75' height='75' class='zip'></a> "; } echo " </span> <span class='action'> <input type='file' name='photo_1' class='zip'><br><br> <input type='checkbox' name='delete_1'>Select to Delete image </span> </div> } this is the code of what to do with that image if (isset($_POST['delete_1'])) { $query = "UPDATE photos SET photo_1='' WHERE userID='$clientID'"; $result = mysql_query($query) or die(mysql_error()); echo " <div id='aboutUpdate'><img src='img/loader.gif'> Information is updating</div> "; echo "<meta http-equiv=refresh content=\"0; URL=photos.php\">"; } else if ($one != NULL) { $extension = strrchr($_FILES['photo_1']['name'],'.'); $extension = strtolower($extension); if($extension != '.jpg' && $extension != '.gif' && $extension != '.png' && $extension != '.bmp' ){ $errorMsg1 == 1; echo "<meta http-equiv=refresh content=\"0; URL=photos.php\">"; } else { $photoNumber="_1"; $finalName="$clientID$photoNumber"; $save_path = "uploads/"; $target_path = $save_path . basename( $_FILES['photo_1']['name']); $NewPhotoName = $finalName; $withExt = $NewPhotoName . $extension; $filename = $save_path . $NewPhotoName . $extension; if(move_uploaded_file($_FILES['photo_1']['tmp_name'], $filename)) { $query = "UPDATE photos SET photo_1='$withExt' WHERE userID='$clientID'"; $result = mysql_query($query) or die(mysql_error()); echo " <div id='aboutUpdate'><img src='img/loader.gif'> Information is updating</div> "; echo "<meta http-equiv=refresh content=\"0; URL=photos.php\">"; } } else { Hi, I am trying to pass a variable when posting a form. This is my form with the select: Code: [Select] <form id="form1" name="form1" method="post" action="products_2.php?id_subcategoria= WHAT SOULD I PUT HERE?"> <select name="subcats" class="subcatsSelectMenu" id="subcats" onchange="this.form.submit()"> <option value="">Ver placas por tipos</option> <?php do { ?> <option value="<?php echo $row_subcats_RS['id_subcategoria']?>"><?php echo $row_subcats_RS['subcategoria_esp']?></option> <?php } while ($row_subcats_RS = mysql_fetch_assoc($subcats_RS));$rows = mysql_num_rows($subcats_RS); if($rows > 0) { mysql_data_seek($subcats_RS, 0); $row_subcats_RS = mysql_fetch_assoc($subcats_RS); } ?> </select> </form>How can I pass the variable in the URL? Thanks |