PHP - Moved: Passing Variables To A Iframe
This topic has been moved to Third Party PHP Scripts.
http://www.phpfreaks.com/forums/index.php?topic=333379.0 Similar TutorialsI have the following code that outputs a url. It searches my MySQL database for the name of a given item within a theme: $relative = 'http://www.domain.com/wp-content/'; $url1= $relative . 'themes/arjuna-x/itemspec.php?type='; $url2='&item='; <a class="entry-thumbnails-link" href="<?php echo $url1.'Themes'.$url2.$rowThemes['Theme']; ?>"> The output is as follows: http://www.domain.com/wp-content/themes/arjuna-x/itemspec.php?type=Themes&item=(insert variable here) All is good up to this point. My problem however, is that some items (in this case: theme names) have apostrophes in them. For example: April Fool's. This results in breaking my php code. How can I get php to call these variables with apostrophes so that they don't break my php? Hello all, So I've picked up a PHP book in an attempt to learn it. The issue I'm having is preventing me from getting any further. They have me creating a simple order form, but the data is not passing from the HTML page to the PHP Processing file. I know there are other ways of doing this that I'm unaware of, but this code is verbatam to what we are isntructed to type within the book itself. Here is the code orderform.html: Code: [Select] <html> <body> <form action="processorder.php" method="post"> <table border="0"> <tr bgcolor="#cccccc"> <td width="150">Item</td> <td width="15">Quantity</td> </tr> <tr> <td>Tires</td> <td align="center"><input type="text" name="tireqty" size="3" maxlength="3"></td> </tr> <tr> <td>Oil</td> <td align="center"><input type="text" name="oilqty" size="3" maxlength="3"></td> </tr> <tr> <td>Spark Plugs</td> <td align="center"><input type="text" name="sparkqty" size="3" maxlength="3"></td> </tr> <tr> <td>How did you find Bob's?</td> <td><select name="find"> <option value = "a">I'm a regular customer</option> <option value = "b">TV advertising</option> <option value = "c">Phone directory</option> <option value = "d">Word of mouth</option> </select> </td> </tr> <tr> <td colspan="2" align="center"><input type="submit" value="Submit Order"></td> </tr> </table> </form> </body> </html> processorder.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>Bobs Auto Parts - Order Results</title> </head> <body> <h1>Bobs Auto Parts</h1> <h2>Order Results</h2> <?php $tireqty = $_post['tireqty']; $oilqty = $_post['oilqty']; $sparkqty = $_post['sparkqty']; echo "<p>Order Processed at "; echo date('H:i, jS F Y'); echo "</p>"; echo '<p>Your order is as follows: </p>'; echo $tireqty.' tires<br />'; echo $oilqty.' bottles of oil<br />'; echo $sparkqty.' spark plugs<br />'; $totalqty = 0; $totalamount = 0.00; define('TIREPRICE', 100); define('OILPRICE', 10); define('SPARKPRICE', 4); ?> </body> </html> For some reason the values on the processing form dont show up. The only text thats displayed is : Bobs Auto Parts Order Results Order Processed at 17:07, 9th January 2011 Your order is as follows: tires <---- Should be showing the total quantity ordered bottles of oil <---- Should be showing the total quantity ordered spark plugs <---- Should be showing the total quantity ordered Is anyone able to let me know where the error is in this code? The writers website isnt any help.... Regards, sapper6fd I'm creating this URL to pass variables to use from one Page to another:
http://eg10basketbal...Borgman&team=16
My WP site is seeing the first variable but not the second. After some searching I've found this suggestion, but it's not working for me:
function add_query_vars_filter( $vars ) { $vars[] = "nameFull"; $vars[] = "team"; return $vars; } add_filter( 'query_vars', 'add_query_vars_filter' );I tried putting this in the wp-includes/functions.php file of the, but ended up with a fatal error. I have since added it to my theme's functions.php file. There isn't an error, but it doesn't yield recognition of my second variable. hai everybody....
1. can any one let me know how to pass a variable from view to controller in CodeIgniter...
2. if possible send me a complete login application...developed by using CodeIgniter....
Thanks & Regards,
Shankaar.
The code below is a form the gets information from a database and post it into the appropriate field. I am having a problem with the while loop. All the variables before the while loop work just great and echo out how they should. But everything after the while loop does not work. I know it has something to do with the while loop because when I take the while loop out everything works as it should. Can anyone please help me with this? <? $id = $_POST["id"]; $therapy = $_POST["therapy"]; db_connect(); $query=mysql_query("select * from student where student_id = $id") or die ("invalid query"); $row=mysql_fetch_array($query); print "<table width='330' border=0 align='center'> <form method='POST' action='table.php'> <td>*First Name:</td> <td>*Last Name:</td> <tr>"; ?> <td width="157"><input size="23" name="first_name" value="<?php echo "$row[first_name]"; ?>" /></td> <td width="138"><input type="text" size="23" name="surname" value="<?php echo "$row[surname]"; ?>" /></td> </tr> <tr> <td>Level:</td> <td>Therapy:</td> </tr> <tr> <td> <select name="program_level"> <option <?php if ($row[program_level]=='1') echo "selected=yes"; ?> value="1">O&A</option> <option <?php if ($row[program_level]=='2') echo "selected=yes"; ?> value="2">Student</option> <option <?php if ($row[program_level]=='3') echo "selected=yes"; ?> value="3">Supervisor</option> <option <?php if ($row[program_level]=='4') echo "selected=yes"; ?> value="4">Manager</option> <option <?php if ($row[program_level]=='5') echo "selected=yes"; ?> value="5">Director</option> <option <?php if ($row[program_level]=='6') echo "selected=yes"; ?> value="6">Graduate</option> </select> </td> <td> <!-- Auto drop down for therapist names--> <? $query2=mysql_query("select * from therapy_info;"); ?> <select name='therapy'> <? while ($row=mysql_fetch_assoc($query2)){ ?> <option value="<? echo "$row[therapy_name]"; ?>"> <? echo "$row[therapy_name]"; } ?> </option> </select> <!-- End Auto drop down for therapist names--> </td> </tr> <tr> <td>Active:<?php echo "$row[active]"; ?></td> </tr> <tr> <td><select name='active' value='$row[active]'> <option <?php if ($row[active]=='1') echo "selected=yes"; ?> value='1'>Active</option> <option <?php if ($row[active]=='0') echo "selected=yes"; ?> value='0'>Inactive</option> </select> </td> </tr> <?php print "<tr> <td><input type='submit' value='Change' name='button' /></td> <input type='hidden' name='id' value='$id' />"; ?> <input type='hidden' name='$hardcode_session' /> <? print "</tr> </form> </table>"; I'm a newbie here and to php and Javascript. So hello all. I am trying to get a portion of a file name passed from one file (first.php) which displays a MySql table. One of the fields is a link that is supposed to open a popup window (second.php) and begin playing a mp3 file with the flash media player. I have everything (almost) working. The table displays as it should, the link is fine. However, I can not get the popup to open with the dimensions I asked for. It opens in a full size new window. And the mp3 will not play. I get the message from the player "we are unable to connect...etc etc". The file name shows up in the status bar and in the URL window. In the file first.php, the table displays, the links appear to be active. when clicked the new window opens, the file names carry over but I can not get the file to play. The player loads (in file second.php) but I get the message from the player "we are unable to connect...etc etc". I suspect it is in the syntax. I have tried so many combinations I can't list them here and so far I have been unable to find anything on google, etc to answer this. After almost three days I have resorted to here. This may not even be the right place for me. Javascript may be my best bet for all I know. Can someone please look over what I have and at least point me in the right direction? Any help is greatly appreciated as this is my first attempt at a website. Thanks first.php Code: [Select] <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <script language="JavaScript"> <!-- Begin function popUp(URL) { playwindow=window.open(URL, 'name', 'toolbar=0,scrollbars=1,location=1,statusbar=1,menubar=0,resizable=1,width=350,height=250'); } // End --> </script> <script language="JavaScript"> <!-- function openPlayer(URL) { player = window.open('player10.php?','width=350,height=275') } // End --> </script> <?php $username="myusername"; $password="mypassword"; $database="mydb"; mysql_connect('mydb',$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM mytable"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); ?> </head> <body> <table border="1" cellspacing="2" cellpadding="2"> <tr> <th><font face="Arial, Helvetica, sans-serif">Listen</font></th> <th><font face="Arial, Helvetica, sans-serif">f2</font></th> <th><font face="Arial, Helvetica, sans-serif">f3</font></th> <th><font face="Arial, Helvetica, sans-serif">f4</font></th> <th><font face="Arial, Helvetica, sans-serif">f5</font></th> <th><font face="Arial, Helvetica, sans-serif">f6</font></th> </tr> <?php $i=0; while ($i < $num) { $f1=mysql_result($result,$i,"listen"); $f2=mysql_result($result,$i,"field2"); $f3=mysql_result($result,$i,"field3"); $f4=mysql_result($result,$i,"field4"); $f5=mysql_result($result,$i,"field5"); $f6=mysql_result($result,$i,"field6"); ?> <tr> <td><font face="Arial, Helvetica, sans-serif"><a href="javascript:openPlayer('player10.php?<?php echo $f1?>')">Listen</a></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f2; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f3; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f4; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f5; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f6; ?></font></td> </tr> <?php $i++; } ?> </body> </html> SECOND.PHP Code: [Select] <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" > <meta http-equiv="X-UA-Compatible" content="IE=8" > <title>My Title </title> <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" > <script language="JavaScript" type="text/javascript"> <!-- // // Make sure there's some data // if (location.search) { // // Extract the name of the graphics file // var mp3_filename = location.search.substring(1) // // Write the <IMG> tag using the name of the graphics // file (you may need to adjust the SRC text) // document.write('<a href="http://mywebsite.com/+mp3_filename">') } // End --> </script> </head> <body> <object width="400" height="300"> <param name="movie" value="http://fpdownload.adobe.com/strobe/FlashMediaPlayback.swf"> </param> <param name="flashvars" value="src=http%3A%2F%2Fmywebsite.com%2Faudio%2F+mp3_filename"> </param> <param name="allowFullScreen" value="true"> </param> <param name="allowscriptaccess" value="always"> </param> <embed src="http://fpdownload.adobe.com/strobe/FlashMediaPlayback.swf" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="400" height="300" flashvars="src=http%3A%2F%2Fmywebsite.com%2Faudio%2F+mp3_filename"> </embed> </object> </body> </html> I normally don't work with PHP or rather I'm learning as I go..and this is pretty much my last barrier between completing this project. Anyway here are my two files: http://pastebin.com/aThU3akC - file i want to grab values from and pass to the file below http://pastebin.com/kTYHr99p - file that is suppose to display the values in $transmessage Basically I need the variables defined in the first file to be passed and usable in the second and I'm not sure why I can't Hi First post here. Long time reader! I'm looking to gauge the general practices of dealing with variables between pages. I'd always pass my variables through the POST. Im normally always doing a post back and processing the data at the top of the page. I never liked the query string as it open to manipulation, but can see its use for a search results page and saving the url. I came from a ASP background and we would only use session variables for holding user login information as the windows server had a habit of restarting the pool and loosing the session. We didn't want this happening, for example, when doing an e-commerce transaction. We always felt the post was the most robust method. Now Im using php and all the great features it has. I was looking to see what the more experience php developers used and am I right sticking to the post method, or is utilising session a more modern way of doing things. I've a few years experience doing web dev, just thought I touch base on a few issues to make sure I'm still heading in the right direction. Thanks for any advice guys! Hi, I'm trying to pass a variable into a URL and apparently I'm doing it wrong this code is OK Code: [Select] $id = $3; echo '<a href="newPage.php?id=3"></a> If I use Code: [Select] $id = $_GET['id']; echo $id; on the newPage.php, I echo 3 whereas, if I do Code: [Select] $id = $3; echo '<a href="newPage.php?id="'.$id.'"></a> when echo out on the newPage.php it prints out nothing also, in current url look like this: Code: [Select] www.site.com/newPage.php?id= What am I doing wrong? Many thanks I have some function or method. Is there a better design patter to implement this?
function myFunction($a=null,$b=null,$c=null,$d=null,$e=null,$f=null,$g=null,$h=null) { //Do a bunch of stuff }Maybe the second function? function myNewFunction($data=array()) { $data=array_merge(array('a'=>null,'b'=>null,'c'=>null,'d'=>null,'e'=>null,'f'=>null,'g'=>null,'h'=>null),$array); //Do a bunch of stuff }Please provide decision making factors why you would use one approach over the other. Having some problems with PHP session i currently use cookies to log users in, but i have decided to use php session instead but i can get it to work, it simply dose not pass the variables unless include session id in every single link on my website, can anyone tell me where i am going wrong these are the session setting from php.in session.use_cookies = 1 session.use_only_cookies = 0 session.name = usersesid session.auto_start = 1 session.cookie_lifetime = 0 session.referer_check = 1 session.cache_expire = 180 session.use_trans_sid = 1 Any idea why this wont work? Think it has something to with how i'm passing the variables? $latinsk =$row['latinsk']; $ID =$row['id']; //-display the result of the array echo "<ul>\n"; echo "<li>" . "<p style='font-family:verdana;font-size:150%;'><a href='javascript:void()' onclick='window.location.href='search.php?id= '" . $ID . "'&latinsk= '" . $latinsk . "''; parent.scrollTo(0,0); return false'> " .$latinsk . " </a></li>\n</p>"; echo "</ul>"; 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 i hav this url n whenever i click on this url i get som mssg send on my mobile i hav a form whose code is Code: [Select] <form action="formprocess.php method="post"> telephone<input type="text name="telephone> <input type="submit" name="submit"> </form> i want to send telephone as parameter to this url so whenever user enters his telephone he gets d mssg after clicking on submit.....but i hav no idea how to do tht...help me somone plssssssss http://www.abc.in/smsapi/sendsms.php?sendto=9987234123&msg=your I have an online store where users can either purchase products or add them to carts for future purchasing. Here is the code for item.php Code: [Select] <?php error_reporting(E_ALL ^ E_NOTICE); ini_set("display_errors", 1); require ('includes/config.inc.php'); include ('./includes/header.html'); require (MYSQL); include ('./includes/main.html'); if($id = isset($_GET['prodID'])) { $query = "SELECT `prodID`, `product`, `prod_descr`, `image`, `price` FROM product WHERE `prodID`='{$_GET['prodID']}'"; $r = mysqli_query($dbc, $query); $showHeader = true; echo "<div id='right'>"; while($row = mysqli_fetch_array($r)) { if($showHeader) { //Display category header echo "<h1>" . "<span>" . "# " . "</span>" . $row['product'] . "<span>" . " #" . "</span>" . "</h1>"; echo "<h2>" . $row['prod_descr'] . "</h2>"; echo "<img src='db/images/".$row['image']."' />"; $showHeader = false; $price = $row['price']; $product = $row['product']; echo '<form target="paypal" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_s-xclick"> <input type="hidden" name="item_name" value="<?php echo $product; ?>"> <input type="hidden" name="amount_x" value="<?php echo $price; ?>"> <input type="hidden" name="hosted_button_id" value="7UCL9YCYYXL3J"> <input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_cart_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> <img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"> </form>'; } } echo "</div>"; } include ('./includes/footer.html'); ?> It displays a product based from a search made. Here is what I want to do? (I have already created test accounts, buttons, etc using PayPal Sandbox) 1. Dynamically pass a variable from when I add a chosen item 2. When my cart loads in Sandbox testing, display the appropriate price, product name, etc, based on the variable or value passed. When I set this up (Add To Cart button) I created default item name and price values, yet I do not want to do this manually using Sandbox. I apologise is this appears rather confusing and still being someone relatively new to PHP, I could do with a better understanding of this but I need some serious help please with this dilemma. Is it possible to use PHP variables in a jQuery file that is including in the header of the file? If so, how? Right, so I've made a very simple web app that allows.... 1.) People to register (adding them to the MySQL database) 2.) Login (providing they're in the database) I've gotten it all working, but I'm stuck at the last hurdle. If someone logs in using the correct username and password, it takes them to login_success.php. Here I query the database and use "SELECT * FROM Users WHERE Username = '$name'" I would have thought, that it would have returned that user's entry in the database. But instead I just get a blank page. Am I right in thinking that's because the contents of the $name variable aren't passed from log.php to login_success.php If so, how do I fix it? ---------------------------------------------------------------------------------------------------- LOGIN.PHP Code: [Select] <?php include_once "Common/header.php"; session_name("MyLogin"); $page = (isset($_GET['login']) ? strtolower($_GET['login']) : NULL); if($page == "failed"){ print $_GET['cause']; } ?> <div id="main"> <br />   <br />  <br /> <h2>Sign In</h2>   <form name="form1" method="post" action="log.php?action=login"> <b>Username:</b>  <input type="text" name="uname"/><br />  <br /> <b>Password:</b>                 <input type="password" name="pword" /><br />  <br /> <input type="submit" value="submit" /> </form> <?php include_once "Common/footer.php"; ?> LOG.PHP Code: [Select] <?php session_name("MyLogin"); session_start(); if($_GET['action'] == "login") { $conn = mysql_connect("localhost", "root", ""); $db = mysql_select_db("test"); $name = ($_POST['uname']); $word = ($_POST['pword']); $sql = "SELECT * FROM Users WHERE Username='$name' and Password='$word'"; $q_user = mysql_query($sql) or die(mysql_error() . ' <br /> in ' . $sql); if(mysql_num_rows($q_user) == 1){ $_SESSION['uname'] = $_POST['uname']; header("Location: login_success.php"); exit; } else{ header("Location: login.php?login=failed&cause=".urlencode('Invalid Username or Password')); exit; } } else{ header("Location: login.php?login=failed&cause=".urlencode('Invalid User')); exit; } if(session_is_registered("name") == false) { header("Location: login.php"); } ?> LOGIN_SUCCESS.PHP Code: [Select] <?php include_once "Common/header.php"; $connect=mysql_connect("localhost", "root", "")or die ("Could not connect to database"); $data = mysql_query("SELECT * FROM Users WHERE Username ='$name'") or die(mysql_error()); Print "<table border cellpadding=3>"; while($info = mysql_fetch_array( $data )) { Print "<tr>"; Print "<th>First Name:</th> <td>".$info['First_Name'] . "</td> "; Print "<th>Last:</th> <td>".$info['Last_Name'] . " </td></tr>"; } Print "</table>"; ?> Login Successful <?php include_once "Common/footer.php"; ?> Hi there,
I want to pass a input variable from login_success.php which will be sent to sqlprocess.php as the variable 'SQLinput';
sqlprocess.php
$link = mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $query = $_REQUEST['SQLinput']; //You don't need a ; like you do in SQL $result = mysql_query($query); $numfields = mysql_num_fields($result);login_sucess.php <form action="" method="post" <label> <span>SQL Input :</span> <input type ="text" id="message" name="SQLinput" placeholder="Input SQL"></textarea> </label> <label> <span>SQL Output :</span> <output id="text" id="SQLoutput" ></input> <script type="text/javascript" charset="utf-8"> // handles the click event for link 1, sends the query function getOutput() { getRequest( 'sqlprocess.php', // URL for the PHP file drawOutput, // handle successful request drawError // handle error ); return false; } // handles drawing an error message function drawError () { var container = document.getElementById('output'); container.innerHTML = 'Bummer: there was an error!'; } // handles the response, adds the html function drawOutput(responseText) { var container = document.getElementById('output'); container.innerHTML = responseText; } // helper function for cross-browser request object function getRequest(url, success, error) { var req = false; try{ // most browsers req = new XMLHttpRequest(); } catch (e){ // IE try{ req = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { // try an older version try{ req = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ return false; } } } if (!req) return false; if (typeof success != 'function') success = function () {}; if (typeof error!= 'function') error = function () {}; req.onreadystatechange = function(){ if(req .readyState == 4){ return req.status === 200 ? success(req.responseText) : error(req.status) ; } } req.open("GET", url, true); req.send(null); return req; } </script> <a href="#" onclick="return getOutput();"><button type="submit" id="search_btn" value="Submit">Submit</button> </a> <div id="output">waiting for action</div>Prior to the JS code - I was able to peform this action - however the JS code enables me to post the query onto the same page. I would like essentially like to query the database through an input box and output the same result on the same page. Thanks! |