PHP - Help With Passing Url (not The Usual)
hi all. i am so lost here guys,i need your help.
basically, i have 3 pages here. _add_tsubject, _query_subject, and _do_addtsubject. _add_tsubject here contains a livesearch javascript that searches for subjects which i query in _query_subject. the result of that is displayed in _add_tsubject. i am using get method for that and for the url. now, my problem is how to pass or should i say combine the url from _add_tsubject with the url inside the <a href> in _query_subject?or is it possible??i'm sorry if it sounds confusing. but if it's confusing you please have a look at the code.. _add_tsubject <?php include("dbconnection_wmsuipil.php"); $id = $_GET['item']; $t_id = $_GET['t_id']; $lname = $_GET['lname']; $fname = $_GET['fname']; $result= mysql_query("SELECT * FROM tblSetSY")or die(mysql_error()); while($row = mysql_fetch_array($result)) { $setYear=$row['SchoolYear']; $setSem=$row['Sem']; } ?> <!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>Adding subject to teacher..</title> <link rel="stylesheet" href="style.css"/> <link rel="stylesheet" href="validator_style/screen.css"/> </head> <body> <div style="margin-right:30px; padding:10px;" align="right"><a href="#" onclick="window.location.reload()">Reload</a> | <a href="#" onclick="window.close()">Close</a></div> <form name="form" id="cmxform_sched" class="cmxform" method="post" action="_do_addtsubject.php"> <fieldset> <p> <label for="t_id">Teacher ID: </label> <input type="hidden" name="school_year1" value="<?php echo $setYear;?>"/> <input type="hidden" name="sem1" value="<?php echo $setSem;?>"/> <input type="hidden" name="id" value="<?php echo $id;?>" size="15"/> <input type="text" name="t_id" value="<?php echo $t_id;?>" size="15"/> </p> <p> <label for="name">Name: </label> <input type="text" name="name" value="<?php echo $fname.' '.$lname;?>" size="25"/> </p> <p><i>*Add subjects to be handled...</i></p> <p><label for="keyword">Enter Subject ID: </label> <input type="text" name="sid" id="sid" size="15" onkeyup="showResult(this.value)" /> </p> <div id="livesearch" align="center"><b>->Subject info will be listed here<-</b></div> </table> </fieldset> </form> <script type="text/javascript"> function showResult(str) { if (str.length==0) { document.getElementById("livesearch").innerHTML=""; document.getElementById("livesearch").style.border="0px"; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("livesearch").innerHTML=xmlhttp.responseText; document.getElementById("livesearch").style.border="1px solid #A5ACB2"; } } xmlhttp.open("GET","_query_subject.php?q="+str,true); xmlhttp.send(); } </script> </body> </html> _query_subject (i get an error on the _POST here..) <?php include("dbconnection_wmsuipil.php"); $t_id=$_POST['t_id']; $name=$_POST['name']; $sy=$_POST['school_year1']; $sem=$_POST['sem1']; $q=$_GET['q']; $sql="SELECT * FROM admin_subject WHERE subj_id like '%".$q."%'"; echo "<table border='1'> <tr> <th>#ID</th> <th>Subject ID</th> <th>Subject Code</th> <th>Description</th> <th>Lect</th> <th>Lab</th> <th>Units</th> </tr>"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)) { $OutLine = array('id'=>'','subj_id'=>'','subj_code'=>'','subj_desc'=>'','lecture'=>'','laboratory'=>'','units'=>''); $OutLine['id'] = $row['id']; $OutLine['subj_id'] = $row['subj_id']; $OutLine['subj_code'] = $row['subj_code']; $OutLine['subj_desc'] = $row['subj_desc']; $OutLine['lecture'] = $row['lecture']; $OutLine['laboratory'] = $row['laboratory']; $OutLine['units'] = $row['units']; $countTsubj=0; if($row>$countTsubj) { echo "<tr>"; echo "<td>".implode('<td/>',$OutLine); echo '<td><a href="_do_addtsubject.php?id='.$row['id'].'&subj_id='.$row['subj_id'].'&code='.$row['subj_code'].'&desc='.$row['subj_desc'].'&lect='.$row['lecture'].'&lab='.$row['laboratory'].'&units='.$row['units'].'">[Add]</a></td>'; echo "</tr>"; } } echo "</table>"; ?> _do_addtsubject <?php include("dbconnection_wmsuipil.php"); $t_id=$_POST['t_id']; $name=$_POST['name']; $sy=$_POST['school_year1']; $sem=$_POST['sem1']; $id=$_GET['id']; $subj_id=$_GET['subj_id']; $code=$_GET['code']; $desc=$_GET['desc']; $lect=$_GET['lect']; $lab=$_GET['lab']; $units=$_GET['units']; echo $t_id; echo $name; echo $sy; echo $sem; echo $id; echo $subj_id; echo $code; echo $desc; echo $lect; echo $lab; echo $units; ?> there guys..i hope you can help me..the last page is where plan to echo the url once it's combined..please please help.. Similar TutorialsHi there, I am a highly concerned about ever using global variables (as many guides I have seen on security issues with PHP say you should avoid them, kind of understand why though to be fair), but I was wanting to really understand custom based session handlers in PHP and this first one he http://uk.php.net/manual/en/function.session-set-save-handler.php on the example: 'Example #1 session_set_save_handler() example' uses them. Now would it be better to take the global variable in function: ''open()' and then return the variable $sess_save_path then pass it up to the next function that may need it perhaps? I just don't want to use globals if I can avoid it, been working out a system that work use for some old solution we use and it uses globals and it really bugs the living life out of me, why people are so lazy they can't avoid them at all costs grrr. Any advice generally speaking is of great appreciation, Jeremy. Code: [Select] <?php $parentesco .=' <ul><li><a href="children.php?category_id='.$idc.'&name= '. $name2 . '">'. $name. ' </a></li></ul>'; ?> in the url string $idc is passing but $name2 is not. $name2 is pickup from a query, I echo that value everywhere in the code and it echo its value but is not passing so how. Help 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. Ok quick run down... I need to pass a variable from one page[form] to another while skipping a page that is in the middle. The middle page is paypal... after they pay, they are being redirected to a thank you for registering with a email also being sent. But I need their email from the first page[form]. so what i need to figure out or help is: 1. First page is a form, they enter name, last name, address, email and so on 2. They are redirected to paypal to pay for a service. 3. Are directed back to my site for a email to be sent to them, but I need their email from the first page. $seat_s is a $var that can have multiple values depending on a form in a previous page. this code works fine as is, but i need to pass the array into a 3rd page. i have no idea how to do this from the code below. ive tried passing the array straight into a _post then _get on the next page but that only holds the 1st value and not all of them. suggestions please.... thanks <?php $seat_s = $_POST['seats']; foreach($_POST['seats'] AS $seat) { $rowId = substr($seat, 0, 1); $columnId = substr($seat, 1); echo $rowId . $columnId . ", "; } ?> I am storing thousands of titles in mysql and many of these have a title with an ampersand. An example is how AT&T is getting stored in the database: at-amp-t Easy enough, I thought.. I'll just run str_replace on it before I save it to the database. $title = str_replace("-amp-", "&", $title); That works great.. except when I click the new hyperlink created from this url. It looks correct... showing the exact url of what is stored in mysql: (http://www.domain.com/this-is-the-at&t-title) ...but no url with this ampersand works. All other $title urls works great. If I don't run str_replace on it, it works fine.. but then I get a url stored as at-amp-t... which I'm trying to avoid. Thoughts? i am sending a mail to user (user's email is stored in $email) in body i have written code $message =" <a href='http://www.example.com/thankyou.php?email=".$email."'>click here to join</a> "; now i need this content to be stored in database and has to be retreived and append it to body like $message =$body_from_db; if i check it in mail. the corresponding value of $email is not coming . pls help guys. Hi guys
I would like to get whole content of html file after I submitted a password. The problem is that the my code doesn't access the value for the file. I tried to create a session but i doesn't work. What other option do I have to get the content of the html file?
session_start(); $selected_file = $_POST['radio1']; // get the filename of the file $fileinfo = pathinfo($selected_file); $filename = $fileinfo['dirname'] . DIRECTORY_SEPARATOR . $fileinfo['filename']; $password = 'code'; $lines = file("$filename.html"); $_SESSION['selectedfile'] = $selected_file; $_SESSION['file'] = $filename; $_SESSION['Scipt'] = ("$filename.html"); $_SESSION['Scipttext'] = $lines; $_SESSION['file2'] = $fileinfo; if (isset($_POST['submitradio'])) { echo '<div class="imageselected">'; echo '<img src="'.$_SESSION['selectedfile'].'" /></br>'.PHP_EOL; echo '</div>'; // check to see if a html file named the same also exists if(file_exists($_SESSION['Scipt'])) { echo "<form action='test_result.php' method='post'>"; echo '<div class="Password">'; echo 'Type in password to view full Script'; echo "<label><div class=\"Input\"><input type='password' name='passIT' value='passit'/></div>"; echo "<input type='submit' name='submitPasswordIT' value='Submit Password'/></div>"; echo '</div>'; echo "$filename.html shares the same name as $selected_file"; for($x = 1;$x<=15;$x++) { header( "Content-Type: file/html" ); $lines = ($_SESSION['Scipttext']); $new = strip_tags($lines); echo $lines[rand(0, count($lines)-1)]."<br>"; } // end of forloop } // end of check // start Sorrytext else { echo '<div class="NoScript">'; echo "Nothing available at the moment."; echo '</div>'; } // end Sorrytext } // End of submitradio if($_POST['submitPasswordIT']){ if ($_POST['passIT']== $password ){ echo "You entered correct password"; readfile($_SESSION['Scipt']); } else{ echo "You entered wrong password"; } } echo '</form>';I would be grateful for help. I cannot figure this out and I know I'm just looking past the obvious... I am creating a simple "you are now leaving this website" page, Everything is setup, and all urls pointing to http://mysite.com?exit=http://externalsite.com, It should redirect to my exit.php which will redirect to the external site after 5 seconds. The problem is, the "http://" of the external site is causing a 403 forbidden, and even without it, anything with multiple &s isn't passing through. I cannot figure out how to get it to pass the full url to the exit.php... Hellooo, I have a map on my site, a user types in there postcode, and clicks next, then a new page opens, the latitude and longitude, is passed from page one, to page two, the user then types in their details and clicks send. The details are then sent to me. But the latitude and longitude is not being sent in the email. Heres a breakdown of my code. Page one. Code: [Select] <form method=LINK name="form1" action="apply.php"> <input name="latitude" type="hidden"/> <input type="hidden" name="longitude"/> <input type="submit" value="Submit"> </form This adds the variables to the URL and passes them to next page. Page two Code: [Select] <?php $latitude = $_GET['latitude']; $longitude = $_GET['longitude']; ?> This grabs the variables and then. Code: [Select] <?php echo "<input type='text' name='Longitude' value='{$latitude}'>"; ?> this places it into a text box, i then send the form just like any others, but it doesnt come through in the email. just blank any suggestions or any better way to do this? Thanks 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. //i've been looking at this same code for two whole days now and ive changed it lots of times but it can only get worse //i can't pass the value of the variable $today which has a date datatype //this is the part where i get the value of $today <?php $query="SELECT DISTINCT today FROM arrastre order by today desc"; $result=mysql_query($query); while($row=mysql_fetch_object($result)){ $today=$row->today; echo "<option value=$today>$today</option>"; } ?> //here's is the part where i use $today to get $tcl //except for a major problem that when the while loop returns more than one $tcl, i get more than one button, but that's not the problem because that is how it's supposed to work. The problem is that when there are more than one buttons, only the last button would work, the only button that displays values <?php if(isset($_POST['godate'])){ $today=$_POST['today']; $query="SELECT DISTINCT tcl FROM arrastre WHERE today='$today' ORDER BY tcl ASC"; $result=mysql_query($query); while($row=mysql_fetch_array($result)){ $tcl=$row['tcl']; $today=$row['today']; ?> <input type="hidden" name="tcl" value="<?php echo $tcl;?>"> <input type=submit name="tcl" value="<?php echo $tcl; ?>"> <?php } } ?> //thsi is another problem if(isset($_POST['tcl'])){ $tcl=$_POST['tcl']; $today=$_POST['today']; $query = "select * from arrastre where tcl=$tcl and today='$today' order by tcl asc"; $result = mysql_query($query); $totalcollections = 0; while($row=mysql_fetch_array($result)){ $orno=$row['orno']; $billnmbr=$row['billnmbr']; $payor=$row['payor']; $arrastre=$row['arrastre']; $wharfage=$row['wharfage']; $total=$row['total']; $today=$row['today']; //*i deleted the display part to make this shorter a little }} //the $today variable is empty in this post and i have no idea how to successfully pass this value so i could use it in my $query //thanks for your time Can anyone explain to me why this system isnt working? I have no clue why it shouldnt be. The pin number is passed from a form to this script, which then determines if a users pin is correct and if so, forwards them onto the relevant page. Otherwise, it returns them to the login. <?php session_start(); $pin=$_POST['pin']; if ($pin='7221') { $_SESSION['pin']='7221'; $_SESSION['name']='Keith D Whelpton'; header('Location: phonesystem.php'); } elseif ($pin='3585') { $_SESSION['pin']='3585'; $_SESSION['name']='Luke S Barnes'; header('Location: phonesystem.php'); } else { header('Location: phonelogin.php'); } ?> 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! 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 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? 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. :/ how can i pass more then one value via href with this kind of method echo "<a href=\"submit_docs.php?prop_id=".$prop_id."\">Click </a>"; tnx 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 hey guys i am stuck at one part. i am coding a site where on the index page there are 5 categories. Now on click of these it takes me to a page where i can search within a particular category. i can do it by statically giving <href="localhost/xampp/abc.php">and a fixed page path. but i want the name of the category passed when i click and the search page to open when i open search. thanks |