PHP - Sending Variables To Another Page
i have problem :
I have a page(page1) that sends details to the login page(page2) to check if the details are correct checks these and if there is a match it directs them to the next page.(page 3) The page1 sends 3 details to the page 2 that are stored into variavles but as there is no submittion when they check the details how do i then send these details onto the page 3 ? Similar TutorialsI'm not sure if this question is better asked here or in the 'other' category in client side but that category of forums has less traffic so i'm posting here. I am trying to mix php, mysql, and flash all togather. In mysql ive got a table with information regarding my photo gallery (columns are like 'id' 'location' 'date' 'uploader' ect) I am using php to pick 5 random pictures and return those 5 picture locations into 5 different php variables. NOW MY ISSUE: How can I send those 5 php variables into flash (as3) as 5 as3 variables??? Any help would be appreciated! Here are the project of files: So the problem I'm running into is, while php ---> php is fine (it's recovering all of my variables, I've tested with echo), the problem seems to be where I have made a command ./createlisting.sh $itemno $title $header $description $image It reads in $itemno, $title, $header $description just fine, but it fails when I try to send an image. Again I've echoed it out and my $image variable contains the correct image name. When it gets sent to the bash script and the bash script sends it to a "log.txt" it only shows $1 thru $4, excluding the $5. When I try to use the img src to create the image on the page, the outputting echo on the page is <img src ="/images/" /> Which of course is going to result in nothing. What advice can you guys offer me? Thanks! createPage.php: <html> <body> <form enctype="multipart/form-data" action="submitForm.php" method="post"> Item#: <input type="text" name="itemno" value="1" /><br /> Title: <input type="text" name="title" value="My Listing" /><br /> Header: <input type="text" name="header" value="ENTER YOUR LISTING" /><br /> <textarea name="description" cols="60" rows="20"> You will have to use quotes on anything that has more than one word. Sorry! </textarea><br><br /></p> <input type="hidden" name="MAX_FILE_SIZE" value="100000" /> Choose an image to upload: <input name="uploadedfile" type="file" /><br /> <input type="submit" value="Submit" /> </form> </body> </html> submitForm.php: <?php $itemno = $_POST["itemno"]; $title = $_POST["title"]; $header = $_POST["header"]; $description = $_POST["description"]; // Where the file is going to be placed $target_path = "/home/images/"; /* Add the original filename to our target path. Result is "uploads/filename.extension" */ $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); $image = 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!"; } $command = "." . "/" . "createlisting.sh"; $param = $itemno . " " . $title . " " . $header . " " . $description; $finalimage = $image . ""; $final = $command . " " . $param . " " . $finalimage; passthru($final); createlisting.sh: #!/bin/bash #Create the page based on the information cd logs echo $1 > log.txt echo $2 >> log.txt echo $3 >> log.txt echo $4 >> log.txt echo $5 >> log.txt cd .. ./createNewDir.sh $(date +%m%d%Y) cd .. cd listings cd $(date +%m%d%Y) mkdir $1 cd $1 echo "<HTML>" > listing.html echo "<Head>" >> listing.html echo "<Title>" >> listing.html echo "$2" >> listing.html echo "</title>" >> listing.html echo "</head>" >> listing.html echo "<body>" >> listing.html echo "<h1>$3</h1><br>" >> listing.html echo "<img src=\"/images/$5\" />" echo "$4" >> listing.html echo "</body>" >> listing.html echo "</html>" >> listing.html cd .. cd .. cd .. cd scripts echo $(date +%d%m%Y); I have this script which I will post below.. the problem is that the following script only works with number.. when I use this script the error.txt will only write numbers and if I send text like... ?trueId=hey nothing happens but ?trueId=1 works just fine.. heres the script Code: [Select] <?php $handle = fopen('error.txt', 'r+'); $trueId = $_GET[trueId]; $nextLine = false; $realText = false; while(!feof($handle) && $realText != $trueId) { $nextLine = fgets($handle); $realText = $nextLine + "\n"; } if($realText != $trueId){ $break = "\n"; $text = $trueId; fwrite($handle, $break); fwrite($handle, $text); fclose($handle); ?> THANK YOU! Appreciate the help! Good afternoon everyone, probably just a quick one this one! I have a reg form, and once the user has been added to the database then it is meant to send them an email with their username and password. The email works fine, received as it should, however the place where I am trying to echo variables is blank. For instance Code: [Select] <style type='text/css'> h3 { font-family: Tahoma, Geneva, sans-serif; font-size: 24px; font-style: oblique; color: #00F; } </style> <body> <img src='https://www.buy2earn.co.uk/images/logo.png' width='240' height='100'> <hr> <h3>Welcome to buy2earn.co.uk!</h3> <p> Welcome <?php echo $username:?> just shows Welcome ................... How do I send the variables in the email? Cheers Mind you, I've altered and butchered my code several times trying to find why it's not sending anything even though it says it does.
geo.html
navigator.geolocation.getCurrentPosition(GetLocation); function GetLocation(location) { var usr_lat = location.coords.latitude; var usr_long = location.coords.longitude; $.ajax({ url: 'local_settings.php', type: 'POST', data: { user_lat : usr_lat, user_long : usr_long }, success: function(data) { alert("success! user_lat:" + data); } }); } ...to obtain an id_item users doesn´t know and I need to send to the DB
I got this
<?php require_once('Connections/conexxion.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO movimiento (venta, compra, taller, regula_mas, regula_menos, id_lente, id_cil, id_esf) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['venta'], "int"), GetSQLValueString($_POST['compra'], "int"), GetSQLValueString($_POST['taller'], "int"), GetSQLValueString($_POST['regula_mas'], "int"), GetSQLValueString($_POST['regula_menos'], "int"), GetSQLValueString($_POST['id_lente'], "int"), GetSQLValueString($_POST['id_cil'], "int"), GetSQLValueString($_POST['id_esf'], "int")); mysql_select_db($database_conexxion, $conexxion); $Result1 = mysql_query($insertSQL, $conexxion) or die(mysql_error()); } mysql_select_db($database_conexxion, $conexxion); $query_lente = "select id_lente, lente from lentes"; $lente = mysql_query($query_lente, $conexxion) or die(mysql_error()); $row_lente = mysql_fetch_assoc($lente); $totalRows_lente = mysql_num_rows($lente); mysql_select_db($database_conexxion, $conexxion); $query_esfera = "SELECT * FROM esfera"; $esfera = mysql_query($query_esfera, $conexxion) or die(mysql_error()); mysql_select_db($database_conexxion, $conexxion); $query_cilindro = "SELECT * FROM cilindro"; $cilindro = mysql_query($query_cilindro, $conexxion) or die(mysql_error()); $query_item = "select id_item from item inner join rx on rx.id_rx = item.id_rx inner join cilindro on cilindro.id_cil = rx.id_cil inner join esfera on esfera.id_esf = rx.id_esf where cilindro = ".$_POST['sel_cil']." and esfera = ".$_POST['sel_esf']." and id_lente =". $_POST['sel_lente']; $idlente = mysql_query($query_lente, $conexxion) or die (mysql_error()); ?> <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1"> <table align="center"> <tr valign="baseline"> <td nowrap="nowrap" align="right">Venta:</td> <td><input type="text" name="venta" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Compra:</td> <td><input type="text" name="compra" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Taller:</td> <td><input type="text" name="taller" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Regula_mas:</td> <td><input type="text" name="regula_mas" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Regula_menos:</td> <td><input type="text" name="regula_menos" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">lente:</td> <td><?php echo "<select name='sel_lente'>"; while($row= mysql_fetch_array($lente)){?> <option value=" <?php echo $row['id_lente'] ;?> " > <?php echo $row['lente']; ?> </option> <?php } ?> </select> <label for="id_lente"></label></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">cilindro:</td> <td><?php echo "<select name='sel_cil'>"; while($row= mysql_fetch_array($cilindro)){?> <option value=" <?php echo $row['id_cil'] ;?> " > <?php echo $row['cilindro']; ?> </option> <?php } ?> </select> <label for="id_cil"></label></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Esfera:</td> <td><?php echo "<select name='sel_esf'>"; while($row= mysql_fetch_array($esfera)){?> <option value=" <?php echo $row['id_esf'] ;?> " > <?php echo $row['esfera']; ?> </option> <?php } ?> </select></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">id_lente</td> <td><label for="id_lente3"></label> <input type="text" name="id_lente" id="id_lente3" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"> </td> <td><input type="submit" value="Insert record" /></td> </tr> </table> <input type="hidden" name="MM_insert" value="form1" /> </form> <?php mysql_free_result($esfera); mysql_free_result($cilindro); mysql_free_result($lente); ?>and with this query $query_item = "select id_item from item inner join rx on rx.id_rx = item.id_rx inner join cilindro on cilindro.id_cil = rx.id_cil inner join esfera on esfera.id_esf = rx.id_esf where cilindro = ".$_POST['sel_cil']." and esfera = ".$_POST['sel_esf']." and id_lente =". $_POST['sel_lente']; $idlente = mysql_query($query_lente, $conexxion) or die (mysql_error());I would obtain the id_item, but , how?, because the form it´s not procesed and I´m getting no variable values. I have been banging my head against a wall for a few days over this and think that I have read so many alternative ways, I have got myself confused! What I am trying to do is post some information into the database and on success, provide certain variables back to my script (for example last_insert_id) as I would like to show a success message an add an option to a select on that page. I am trying to get this part working without the mysql first just so I understand it. Currently I can post the data, have that received successfully in the processing page (addDetail.php) and send back output from that page........ insert.php $("#sub").click(function() { var name = $("#name").val(); var town = $("#town").val(); jQuery.ajax({ type: "POST", url: "postScripts/addDetail.php", data: 'name='+name+'&town='+town, success: function(html) { $(".modal-body").prepend( "Returned: " +html ); } }); return false })addDetail.php $name = $_POST['name']; $town = $_POST['town']; //Check $_POST data echo "<pre>"; print_r($_POST) ; echo "</pre>"; $return["name"] = $name; $return["town"] = $town; echo json_encode($return); Result in insert.php Returned: Array ( [name] => The Name [town] => The Town ) {"name":"The Name","town":"The Town"}This works fine to bring back everything on the processing page in one go but I want to bring back separated variables so I can use them individually. I thought that changing "Returned: " +htmlto "Returned: " +html.namewould allow me to bring back just that variable but it comes back undefined. This is the closest I have got as other methods I tried either brought nothing back or just [objectObject]. How would I be able to bring back both 'name' and 'town' as separated values so I can use them individually in my script? Thanks in advance Steve Edited by MargateSteve, 29 September 2014 - 08:41 AM. Hey ive been wanting to know how to make a function call another function which will then create a variable which i can send back to first function where i can use it. I tried somthing like this Code: [Select] <?php a(); function a($wall) { b(); echo $wall; } function b() { $wall = "test"; #a($wall); } ?> Thats what i tried but ofcourse didnt work, how would i go about doing this? Thanks. I have this simple while loop which retrieves data from a mysql query and displays several links on my homepage. I would like to avoid using the php get function and add query strings to my urls I am thinking of using session variables but I need help and I'm pretty sure this can't be done. When a visitor clicks a link from the several ones displayed by the while loop, that particular variable would be set in a session. In my code, the session will always send the last var Can this be done? Code: [Select] <? session_start(); // Start Session Variables $result = mysql_query("my query"); while($slice = mysql_fetch_assoc($result)){ $url = $slice['url']; $name = $slice['name']; ?> <a href="<? echo $url; ?>"><? echo $name; ?></a> <? } $_SESSION['name'] = $name; // Store session data ?> ok well my registration page is supposed to send out an email so the user can activate his or her account , but it will not send! i am using xampp for my local webhost and my php.ini settings are [mail function] ; For Win32 only. ; http://php.net/smtp SMTP = relay.jangosmtp.net ; http://php.net/smtp-port smtp_port = 587 ; For Win32 only. ; http://php.net/sendmail-from sendmail_from = activate.social@gmail.com sendmail_path="\"C:\xampp\sendmail\sendmail.exe\"-t and my sendmail.ini is account Gmail tls on tls_certcheck off host relay.jangosmtp.net from activate.social@gmail.com auth on user activate.social@gmail.com password mypassword port 587 account default : Gmail and now here is my php script that sends the mail but it wont send , the reason i put those .ini files in here is because that is what xampp uses to send mail. here is the php script Code: [Select] <?php $to = "$email1";// which is established further up on the script which is to big! $from = 'activate.social@gmail.com'; // same email used in php.ini and sendmail.ini but wont send $subject = 'Complete Your ' . $dyn_www . ' Registration'; //Begin HTML Email Message $message = "Hi $username, Complete this step to activate your login identity at $dyn_www Click the line below to activate when ready http://$dyn_www/activation.php?id=$id&sequence=$db_password If the URL above is not an active link, please copy and paste it into your browser address bar Login after successful activation using your: E-mail Address: $email1 Password: $pass1 See you on the site!"; //end of message $headers = "From: $from\r\n"; $headers .= "Content-type: text\r\n"; mail($to, $subject, $message, $headers); // supposed to send but wont ?> Hi guys, basically my problem is I have a jquery pop out window that holds a login form using the "require_once" function but when I enter my login details and send them, if there is another another form on the page e.g contact form it will send that form aswell so it will come up for the errors for the register form because they are empty. can anyone tell me how to stop this from happening? I'm curious about the mechanics of the script execution here. One page in my project sends out batch emails to all users who are registered. That part is simlple enough, but in order to do it, my page has to connect to a remote SMTP server and then submit all the recipients and messages. This process can take a little bit of time, usually 5 seconds or so. If the user hits the stop button or navigates away while my script is still executing, will it mess up the emails that are being sent? If so, what other way should I restructure my script to make it more robust? The first thing that comes to my mind is adding them to some sort of queue in the database and then have a separate script that checks periodically for messages that need to be sent and then send them. The only way to do this, though, would be to make a script designed to be called by cron, and that somewhat complicated the installation of my script which I'd like to avoid. Hi there, Any help is greatly appreciated. I've commented out the code giving me trouble. Error = <br /> <b>Warning</b>: curl_setopt(): supplied argument is not a valid cURL handle resource in <b>/###.php</b> on line <b>34</b><br /> <br /> <b>Warning</b>: curl_setopt(): supplied argument is not a valid cURL handle resource in <b>/###.php</b> on line <b>35</b><br /> <?php $ch = curl_init(); $timeout = 30; $userAgent = $_SERVER['HTTP_USER_AGENT']; if ($_REQUEST['update']) { curl_setopt($ch, CURLOPT_URL, $_REQUEST['url']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($ch, CURLOPT_USERPWD, $_REQUEST['username'] . ':' . $_REQUEST['password']); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); //curl_setopt($c, CURLOPT_POST, true); //curl_setopt($c, CURLOPT_POSTFIELDS, $_REQUEST['update']); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); $response = curl_exec($ch); if (curl_errno($ch)) { echo curl_error($ch); } else { curl_close($ch); echo $response; } } HI, I am trying to use pagination on the record getting displayed into the table and there's restriction on record that at a time total 15 records can be displayed and others will be displayed by clicking on NEXT (on which i did the following coding). In my SQL query 'where' clause there is select * from db where status = $query Code: [Select] <?php if ($pageNum_Recordset1 < $totalPages_Recordset1) { // Show if not last page ?> <a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, min($totalPages_Recordset1, $pageNum_Recordset1 + 1), $queryString_Recordset1); ?>?id=<?php echo $yes;?>">Next</a> <?php } // Show if not last page ?> The problem that i am facing is when i click on next then the $query gets equal to null which results to showing no record into the table kindly help how can i modify the above code so the previous value present in $query doesn't get NULL by clicking on next and show next 15 records sucessfully??? NOTE: The main purpose of the above mentioned code is to show next 15 records (which works fine if $query != NULL). From our website we are connecting to GMAIL to send our emails through SMTP. For some reason it is not sending the emails to the CC or BCC email address event though GMAIL shows it was included in the email. Am I missing something in the below code? Code: [Select] $currentTime = time(); $emailTo = "redbrad0@domain.com"; $emailCC = "brad@domain.com"; $emailBCC = "events@domain.com"; $emailSubject = "TEST Email at (" . $currentTime . ")"; $emailBody = "This is the body of the email"; $headers = array(); if (!empty($emailTo)) $headers['TO'] = $emailTo; if (!empty($emailCC)) $headers['CC'] = $emailCC; if (!empty($emailBCC)) $headers['BCC'] = $emailBCC; if (!empty($emailSubject)) $headers['Subject'] = $emailSubject; $headers['From'] = "events@domain.com"; $mime = new Mail_mime("\n"); $mime->setTXTBody($emailBody); $body = $mime->get(); $headers = $mime->headers($headers); $mail = Mail::factory('smtp', array ('host' => 'ssl://smtp.gmail.com', 'auth' => true, 'port' => 465, 'username' => 'events@domain.com', 'password' => 'thepasswordhere')); try { $result = $mail->send($emailTo, $headers, $emailBody); } catch (TixException $ex) { echo "<font color=red>Error:" . $ex->getCode() . "</font><br>"; } echo "Emailed at (" . $currentTime . ")<br>"; die; How would I pass variables from one page to another without using forms or $_GET features. Let say I have page (1.php) where If define $secret_phrase = "open sesame";. On that page (1.php) I have multiple html links to multiple pages (2.php, 3.php, ...) if you click on the link to 2.php page I would like to pass the $secret_phrase as well without having it encoded into a link or using forms. Is there a way to do it? Thanks Hey people, I know this is going back to basics but i'm just learning and want to make sure I do it all correctly. I want to pass variable's from one page to another. Now currently say I wanted to hold the users age and email address from his record in the database from page A and pass it to page B for it to be displayed back to him I would store each in their own session variable (so for the purpose of the explanation session_user_email=me@email.com and session_user_age=18. On page B I would then call the session and store it in a variable then destroy the session. Just out of curiosity is the the best way to pass the data? or should i use another method? i've read about session hijacking and i'm now worried about holding personal data within a session so i'm wondering what other people do?? Cheers Hey guys, Was wondering if someone could point me on the right path here. I am able to get the page URL using: $url = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; But was wondering if there was a way to drop the PHP variables attached to the URL. e.g. mysite.com/catalogue/?item=23 becomes mysite.com/catalogue/ Can anyone help me out? Thanks! I have a php script which is viewed with ajax. The script does some important things and I want to make sure that it's viewed by only the ajax and now the user so I was thinking I'd need to pass a code from the main page using a GET in either php or more likely javascript, as I don't want the user to be able to see the code and then be able to just copy it and view the script with it. I've tried to sort this by saving Math.random() to the database by using ajax using a separate file, then underneath it use it to access the file like this: Code: [Select] function saveCode() { var xmlHttp = connect(); if(xmlHttp != false) {var code = Math.random(); xmlHttp.open('GET', '/inc/battle/saveCode.php?i='+code, true); xmlHttp.onreadystatechange = function() { if(xmlHttp.readyState == 4) { battleLog = xmlHttp.responseText; battleList = battleLog.split('\n'); battleCount = battleList.length; addLine(); } } xmlHttp.send('null'); } This would save the code to the database, then with a separate function, namely endBattle() the variable code would be used to access a file called endBattle.php?i= where this script would compare the code from the GET variable to the code in the database. However, I realised before finishing this that the user could manually set the code to whatever they want through the saveCode.php page, then view the endBattle.php Does anyone have any ideas how else I could validate my endBattle.php page so that users couldn't view it in their browser to run it? Forgive me if this is in the completely wrong forum, I just thought I'd see whether there were any php methods of doing this. Thanks! Is there anyway I can like "exit" the variables so i can use the same variable name later in the page? |