PHP - Make The Get Automatically Decide To Use ? Or &
This is an example of the forwarding section of the pagination code:
if (($filename == $profile) && isset($select_category)) { echo " <a href='{$filename}?user=$user_name_get&sort_category=$select_category&sortSubmit=submit¤t_page=$next_page'>></a> "; echo " <a href='{$filename}?user=$user_name_get&sort_category=$select_category&sortSubmit=submitcurrent_page=$total_pages'>>></a> "; } elseif ($filename == $profile) { echo " <a href='{$filename}?user=$user_name_get¤t_page=$next_page'>></a> "; echo " <a href='{$filename}?user=$user_name_get¤t_page=$total_pages'>>></a> "; } elseif (($filename == $index) && isset($select_category)) { echo " <a href='{$filename}?sort_category=$select_category&sortSubmit=submit¤t_page=$next_page'>></a> "; echo " <a href='{$filename}?sort_category=$select_category&sortSubmit=submit¤t_page=$total_pages'>>></a> "; } else { echo " <a href='{$filename}?current_page=$next_page'>></a> "; echo " <a href='{$filename}?current_page=$total_pages'>>></a> "; } $filename = the opened filename + extension $profile = profile.php $index = 01.php I'm using several if and elseif statements to not have the pagination clash with the other GET data. I'd like to have the pagination simply append at the end of the URL with an ampersand if there is GET data already. If there's no GET data at all I'd like to have it append with a question mark. The problem with the solution I have now is, if I use more GET data in the future I'll have to use more elseif statements it will get out of hand. I've noticed that if you send GET data over a form that has method on GET, then the GET data will automatically decide if to add a question mark or an ampersand. In that sense my question would be, is there a way to make the pagination decide automatically to use a question mark or an ampersand? Similar TutorialsHi, I was wondering if it is possible to have the foreign keys (FK) to automatically assign its value to the corresponding PK (primary key) it references? Let's say I have four tables (with their PK,FK and other fields) Code: [Select] TABLE document: TABLE pathway: TABLE leaf TABLE value: PK: docID PK:pathID PK:leafID PK:valueID filePath pathway FK:pathID FK:leafID fileName FK:docID value target source So when I upload a document, it is added to TABLE document, where PK docID set, and at same time I would add the filepath to TABLE pathway, and now I want TABLE leaf's FK to AUTOMATICALLY add the pathID, docID and ALSO at same time TABLE value's FK of leafID will also be added for that ONE entry that was initally added to TABLE document, pathway. Please I hope someone understand what I want to do, I know FK is for ensuring integrity of data. Please any help is appreciated. Please use my example to help me, thanks. PS: I know the formatting is off which I noticed when I went to preview the post, sorry. Hi,
I have the following function, but told I need to run it automatically. How would I do this?
<script> function replaceText() { var list = document.getElementsByTagName("UL")[22]; var list2 = list.getElementsByTagName("LI")[29]; list2.getElementsByTagName("LABEL")[0].innerHTML = "Car"; } </script>Thanks! Hello, I am new here but I hope you can help me with a problem that I've been stuck with for days. I am trying to populate the content of a website through XML files (zipped) that are located on an FTP server. I managed to get the zip file but I'm not sure if it is the correct way: Code: [Select] function ftp_copy($file) { $conn_id = ftp_connect($ftp_host) or die ("Can't connect"); $ftp_login= ftp_login($conn_id, $ftp_user, $ftp_pass) or die ("Can't login"); ftp_pasv($conn_id, true); ftp_chdir($conn_id, "/zip_files/"); return ftp_get($conn_id, $file, $file, FTP_BINARY); } ftp_copy('1001.zip'); After that I will need to extract the zip file. I'm planning to use pclzip library for it and save the contents on a database. Also this has to happen everyday so I'm thinking about using a cron job, although hourly is also preferable since the XML files could be generated more than once per day. Am I doing it the right way or is there a better solution for this? Any help will me much appreciated! Thanks a lot! Hi Guys, I have the following $pattern = '<tr class="newsitem">'; when I echo this out it produces <tr class="newsitem"> </tr> Why is it automatically closing the tag? I dont want this becuase i'm using preg_replace and the tag is closed elsewhere already on the page. Hello friends, In this topic i am getting confuse, and never know how to do work. My problem is that: 1>> I want to send SMS, by PHP pages to mobile. 2>> If user write some Quotation into the calender date, then automatically SMS send to all of those friend with the quatation metter. 3>> All work is store also in MYSQL database also. So please tell me what I do in this case because over the internet only SMS sending code is available, but automatically sms sending option is not given. Please help me then i do this job easily. Thanks Hi, I've been wondering if it is possible to load a php page according to certain time. For example at 12:00 pm a php form will pop up automatically informing an employee to fill in something in the form, another form will pop up at 4:00 pm, etc... Thanks in advance Hi Everyone i am looking for a way to automatically upload a file but skip the browse and choose file process. So i set the location of the file somehow via the form and the client just has to click submit and it will automatcially upload the file from the path i have set. skipping the browse for file process. I would like to intergrate it into the following undesigns S3 Class http://undesigned.org.za/2007/10/22/amazon-s3-php-class/documentation <?php S3::setAuth(awsAccessKey, awsSecretKey); $bucket = "upload-bucket"; $path = "myfiles/"; // Can be empty "" $lifetime = 3600; // Period for which the parameters are valid $maxFileSize = (1024 * 1024 * 50); // 50 MB $metaHeaders = array("uid" => 123); $requestHeaders = array( "Content-Type" => "application/octet-stream", "Content-Disposition" => 'attachment; filename=${filename}' ); $params = S3::getHttpUploadPostParams( $bucket, $path, S3::ACL_PUBLIC_READ, $lifetime, $maxFileSize, 201, // Or a URL to redirect to on success $metaHeaders, $requestHeaders, false // False since we're not using flash ); $uploadURL = "https://{$bucket}.s3.amazonaws.com/"; ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>S3 Form Upload</title> </head> <body> <form method="post" action="<?php echo $uploadURL; ?>" enctype="multipart/form-data"> <?php foreach ($params as $p => $v) echo " <input type=\"hidden\" name=\"{$p}\" value=\"{$v}\" />\n"; ?> <input type="file" name="file" />&#160;<input type="submit" value="Upload" /> </form> </body> </html> at what point does it grab the file path ? is it grabbing it out of the name here <input type="file" name="file" /> can i do something with $_FILES ??? Can someone please give me a point on where to start i would really appriciate this. thanks I'm wanting to make a sitemap for my website but as it's quite big there are a lot of url's I need to include. I was wondering if anyone know's of a way this can be done using PHP. e.g. using PHP to generate a list of URL's. I had a think myself but wasn't sure how to do it. Thanks for any help. Hi all, Recently I have found myself repeating a very monotonous task on amazon's kindle direct publishing website and (being the kinda guy I am), I figured I could probably automate it without too much trouble. I'm a publisher who needs to maintain my library of lots of books and ensure that any offers are kept up-to-date. I have made screen scrapes before without too much problem, but filling in forms is a little bit more difficult. There are no CAPCHA images to enter and this is specific to my own login so I don't think I can be considered "evil", so all I want to know is how to automate my own login, click a specific link and fill in forms. Ideally I want it as easy as recording a macro, or maybe just a list of instructions. If I told a human to do it, I'd just say "go to this page and click on that, enter these details to login, then click that" and I wondered if there is something out there in cyber world that allows me to do the same? Thanks, Neil I am very new to PHP and programming in general. About 3 weeks into this. I have this simple expression and some echo in my code. $x1 = $lat_b + $lat_a1; echo "<br>lat b: ".$lat_b; echo "<br>lat a1: ".$lat_a1; echo "<br>x1: ".$x1; $lat_b and $lat_a1 are derived from some xml extractions from a yahoo geocode api (that part works fine). The results of the expression and echos above are as follows: lat b: 40.402866 lat a1: 40.252590 x1: 80 Why is $x1 rounding automatically on me? Later, I substituted the expression above with $x1 = 40.402866 + 40.252590 ; The new result (shown below) makes sense to me. lat b: 40.402866 lat a1: 40.252590 x1: 80.655456 hello guys. i need to run a script automatically at scheduled date and time. i am sending bulk emails . i need to setup an email campaign, in such a way that i can schedule like daily, monthly or quarterly.. can u guys give few tips to get it done.. Okay so my news script is set to view only 10 pieces of news. But I want it so that it starts a new page once I have more than 10 pieces of news. Code: [Select] <?php require("functions.php"); include("dbconnect.php"); session_start(); head1(); body1(); new_temp(); sotw(); navbar(); $start = 0; $display = 10; $query = "SELECT * FROM news ORDER BY id DESC LIMIT $start, $display"; $result = mysql_query( $query ); if ($result) { while( $row = @mysql_fetch_array( $result, MYSQL_ASSOC ) ) { news_box( $row['news'], $row['title'], $row['user'], $row['date'], $row['id'] ); } mysql_free_result($result); } else { news_box( 'Could not retrieve news entries!', 'Error', 'Error', 'Error'); } footer(); mysql_close($link); ?> I tried a few things but they failed....miserably. <?php
require_once('upper.php'); require_once('LoginStatement.php'); require_once('database.php'); echo $error_msg=''; require_once('database.php'); $LoginId=$_COOKIE['LoginIdCookie']; $query="select * from registration where LoginId='$LoginId'"; $result=mysqli_query($dbc,$query); $row=mysqli_fetch_array($result); if(isset($_POST['submit'])) { $LoginId=mysqli_real_escape_string($dbc,trim($_POST['LoginId'])); $Name=mysqli_real_escape_string($dbc,trim($_POST['Name'])); $Age=mysqli_real_escape_string($dbc,trim($_POST['Age'])); $BloodGroup=mysqli_real_escape_string($dbc,trim($_POST['BloodGroup'])); if(!isset($_POST['Sex'])) { echo 'Please enter Sex<br>'; } else{ $Sex= mysqli_real_escape_string($dbc,trim($_POST['Sex'])); } $Qualification=mysqli_real_escape_string($dbc,trim($_POST['Qualification'])); $ContactNumber=mysqli_real_escape_string($dbc,trim($_POST['ContactNumber'])); $Email=mysqli_real_escape_string($dbc,trim($_POST['Email'])); $Address=mysqli_real_escape_string($dbc,trim($_POST['Address'])); $AboutYourself=mysqli_real_escape_string($dbc,trim($_POST['AboutYourself'])); //$countCheck=count($_POST['checkbox']); //echo $countCheck; //$checkbox=$_POST['checkbox']; //$countCheck=count($checkbox); if(empty($LoginId)){echo 'Please enter Login Id';} elseif(empty($Name)){echo 'Please enter Name';} elseif(empty($Age)){echo 'Please enter Age';} elseif(!isset($_POST['Sex'])){} elseif(empty($Qualification)){echo 'Please enter Qualification';} elseif(empty($ContactNumber)){echo 'Please enter Contact Number';} elseif(empty($Email)){echo 'Please enter Email';} elseif(empty($Address)){echo 'Please enter Address';} elseif(empty($AboutYourself)){echo 'Please enter About Yourself';} else { if(mysqli_num_rows($result)==0) { $checkbox=$_POST['checkbox']; $countCheck=count($_POST['checkbox']); $reg_id=' '; for($i=0;$i<$countCheck;$i++) { $reg_id=$reg_id.$checkbox[$i].','; } $query="UPDATE registration SET (LoginId,Name,Age,BloodGroup,Sex,Qualification,ContactNumber,Email,Address,AboutYourself,Activity)values ('$LoginId',SHA('$Password1'),'$Name','$Age','$BloodGroup','$Sex','$Qualification','$ContactNumber','$Email','$Address','$AboutYourself',',$reg_id')"; $result=mysqli_query($dbc,$query) or die("Not Connect"); echo ' Dear '.$Name.'.<br>Your request has been mailed to admin.<br>Your account is waiting for approval<br>'; $from= 'Elite Brigade'; $to='ankitp@rsquareonline.com'; $subject='New User Registration'; $message="Dear admin,\n\nA new user request for registration. Please check it out.\n\nRegards\nMicro"; mail($to,$subject,$message,'From:'.$from); //header('Location: index.php'); // header('Location: Registration.php'); } else { echo 'Dear '.$Name. ', <br> An account already exist with login-id<b> '.$LoginId.'</b> <br>Please try another login-id'; }} } ?> <html> <head> <script src="jquery-latest.js"></script> <script type="text/javascript" src="jquery-validate.js"></script> <style type="text/css"> * { font-family: Verdana; } label.error { color: white; padding-left: .5em; } p { clear: both; } .submit { margin-left: 12em; } em { font-weight: bold; padding-right: 1em; vertical-align: top; } </style> <script> $(document).ready(function(){ $("#commentForm").validate(); }); </script> </head> <body> <?php echo $error_msg; ?> <form action='<?php echo $_SERVER['PHP_SELF'];?>' id="commentForm" method='post'> <div class="registration_and_activity"> <table border="0" width="380"> <tr><td colspan="2"> <h3>Update Personal Details</h3></td></tr> <tr><td width="120"> <em>*</em>Enter Login id</td><td width="150"><input type='text' name='LoginId' minlength='4' value='<?php echo $row['LoginId']; ?>' /></td></tr> <tr><td width="120"> <em>*</em>Enter Name</td> <td><input type='text' name='Name' value='<?php echo $row['Name'];?>' /></td></tr> <tr><td> <em>*</em>Enter Age</td><HEAD> <SCRIPT language=Javascript> function isNumberKey(evt) { var charCode = (evt.which) ? evt.which : event.keyCode if (charCode > 31 && (charCode < 48 || charCode > 57)) return false; return true; } </SCRIPT> </HEAD> <td><INPUT onkeypress='return isNumberKey(event)' type='text' name='Age' value='<?php echo $row['Age'];?>'/></td></tr> <tr><td> <em>*</em>Enter Blood</td><td><input type='text' name='BloodGroup' value='<?php echo $row['BloodGroup'];?>' /></td></tr> [B]<tr><td> <em>*</em>Enter Sex</td><td><input type='radio' name='Sex' style='width:16px; border:0;' value='Male' checked='<?php if($row['Sex']='Male') echo 'checked';?>'/>Male <input type='radio' name='Sex' checked='<?php if($row['Sex']='Female') echo 'checked';?>' style='width:16px; border:0;' 'value='Female' />Female</td></tr>[/B] <tr><td> <em>*</em>Enter Qualification</td><td><input type='text' name='Qualification' value='<?php echo $row['Qualification'];?>' /></td></tr> <tr><td> <em>*</em>Contact Number </td><td><input onkeypress='return isNumberKey(event)'type='text' name='ContactNumber' value='<?php echo $row['ContactNumber'];?>' /></td></tr> <tr><td> <em>*</em>Enter Email</td><td><input type='text' name='Email'class="email" value='<?php echo $row['Email'];?>' /></td></tr> <tr><td> <em>*</em>Enter Address</td><td><input type='text' name='Address' value='<?php echo $row['Address'];?>' /></td></tr> <tr ><td > <em>*</em>About Yourself </td></tr> <tr><td colspan="2"><textarea rows='10' cols='40' name='AboutYourself' /><?php echo $row['AboutYourself'];?></textarea></td></tr> <tr><td> <?php echo "<tr><td colspan='2' align='center'><input type='submit' value='Update' name='submit' style='background:url(./images/button_img2.png) no-repeat 10px 0px; width:100px; padding:3px 0 10px 0; color:#FEFBC4; border:0;'/></td></tr><br>"; echo " </td></tr></table> </div> </form> </body> </html>"; require_once('lower.php'); ?> Hi friends.......... In above code I want that In database if Sex=Male then Male radio button will be checked automatically and if Sex =Female then Female radio button will be checked. But it not works ........... please help me........... thanks in advance.......... Hey guys it's been a long time, but I am back with php! Anyway here's my dilemma: test.php <?php <?php $name = array('Chris', 'Bob', 'Jack'); $names = print_r($name); ?> Simple enough right? Well although I am not printing/echoing these results to screen it does it automatically. Meaning when I point my browser to test.php it outputs this: Code: [Select] Array ( [0] => Chris [1] => Bob [2] => Jack ) Rather than only assigning the value to the $names variable, which is what I would expect it to do. Is this normal behaviour or is there something I can change on php.ini? Thank you! I am creating a drink recipe site. So far I have created the mysql table and the page where i can enter in the drink name ingredients ect. and it inserts into the table. Could some one point me in the right direction where when I make an entry into this table a new page is created from the content. How would I go about doing this? Hi guys, Is it possible to make a page automatically redirect to the previous page a user was in once they submit a form? Thanks I have the following menu that changes to red if each of the menu items are hovered over. This menu shows on every page of my website. I have the following problem: If a user was to click a menu item (e.g. Menu 2), the page will navigation to the page set in the a tag (i.e page2.html) If the user was to leave there mouse in the same position as it was in before the menu item was clicked (i.e. over the selected menu item), then the menu would automatically change to red again on the new page, as the jQuery hover code below will be activated. Is there a way to stop this behaviour? Ideally I want users to have to mouse off of the menu item and then on it again before the menu item changes to red if the users mouse is still over the selected menu item after clicking one of the menu links. <script type="text/javascript"> $(document).ready(function() { $('li').hover(function() { $(this).css('background', 'red'); }, function() { $(this).css('background', 'none'); }) }) </script> <ul> <li><a href="page1.html">Menu 1</a></li> <li><a href="page2.html">Menu 2</a></li> <li><a href="page3.html">Menu 3</a></li> </ul>
I've been working on this html/php page for class and I just don't understand why my code is acting like this. This is my code <?php //error_reporting(E_ALL); //ini_set('display_errors', 1); $title = "Listing Search"; $file = "listing-search.php"; $description = "Listing Search page for real estate website (WEBD3201)"; $date = "2019-10-01"; $banner = "Listing Search page"; require "header.php"; ?> <?php $headline = ""; $minPrice = ""; $maxPrice = ""; $city = ""; $error = ""; $output = ""; $error = ""; $output = ""; if(isset($_GET["city"])) { $city = $_GET["city"]; setcookie('city',$city,COOKIE_LIFESPAN); $_SESSION['city'] = $city; } else if (isset($_COOKIE['city'])) { $city = $_COOKIE['city']; $_SESSION['city'] = $city; } if(!isset($city)) { $_SESSION['RedirectError'] = "Please select a city<br/>"; header("Location:listing-select-city.php"); } if(isPost()) { $minPrice = trim($_POST["minPrice"]); $output .=$_POST["minPrice"]; $maxPrice = trim($_POST["maxPrice"]); $output .=$_POST["maxPrice"]; $headline = trim($_POST["headline"]); $output .=$_POST["headline"]; $city = trim($_POST["city"]); $output .=$_POST["city"]; $error = ""; $output = ""; if($headline == "") { $error .= "<br/>Headline was not specified"; } if($city == "") { $error .= "<br/>City was not specified"; } if($minPrice == "") { $error .= "<br/>Minimum price was not specified"; } elseif (preg_match(PRICE_FILTER, $minPrice) == '0') { $error .= "<br/>Minimum price needs to be a number"; $minPrice = ""; } if($maxPrice == "") { $error .= "<br/>Maximum price was not specified"; } elseif (preg_match(PRICE_FILTER, $maxPrice) == '0') { $error .= "<br/>Maximum price needs to be a number"; $minPrice = ""; } if($maxPrice < $minPrice) { $error .= "<br/>Minimum price must be smaller than maximum price"; } } ?> <?php echo $error; ?> <?php echo $output;?> <h2>Search for a home.</h2> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <table style="margin-left: auto; margin-right: auto;"> <tr> <td> Listing Name </td> <td> <input type="text" name="newlist" value="<?php echo $headline ?>" /> </td> <td> City </td> <td> <input type="text" name="city" value="<?php echo $city ?>" /> </td> </tr> <tr> <td> Min Price </td> <td> <input type="text" name="minPrice" value="<?php echo $minPrice ?>" /> </td> <td> Max Price </td> <td> <input type="text" name="maxPrice" value="<?php echo $maxPrice ?>" /> </td> </tr> </table> <table style="margin-left: auto; margin-right: auto;"> <tr> <td> <input type="submit" value = "Search" /> </td> <td> <input type="reset" value = "Clear" /> </td> </tr> <tr> <td> <?php echo build_checkbox("internet", "DSL"); ?> </td> <td> <?php echo build_checkbox("heating", ""); ?> </td> </tr> </table> </form> <?php require "footer.php"; ?>
I'm quite new to PHP coding and I'm having trouble with what I'm sure is a common beginners problem. What I need is a method that first checks if there's variable being passed through the URL and if there is then pass the new variable with an & instead of a ?. I have been able to do this with a code that looks something like this: Code: [Select] if (isset($_GET['firstvar'])): header ("Location: index.php?firstvar=1&secondvar=2") else: header ("Location index.php?secondvar=2"); endif; The problem with this code is that I always need to adapt it to different parts of the code where "firstvar" is different. So basically what I'm asking is; is there a way to check if any variable is being passed through the URL and if there is then pass a variable beginning with & at the end of the url. P.S I've tried using $_SESSION['REQUEST_URI'] to get the url and pass variables at the end of that. The problem is that I have a pagination function that makes the URL look like www.mywebsite.com/index.php?page=1&page=2&page=3 etc etc. |