PHP - Need Help With Some Php-generated Form Actions
Ok, so I currently have this http://pastebin.com/cCgyavs0 snippet that generates links to the previous, next and last page based on the current page (GET variable) or the total item count in the MySQL DB to then use forms as links by inserting the URLs into the action attribute. I did this cause I don't wanna use images as links, btw :P
It kinda works - I get links like: shop.php?page=1 shop.php?page=12 shop.php?page=14 shop.php?page=225 When I'm on page 13 of 225 for example. Though when I click one of the buttons, I always get redirected to "shop.php?". :/ Similar TutorialsI have a problem regarding with actions. I have a dynamic dropdown list (attached), that when the selected value is student, a form will show..I am using a submit button, the problem is how am I going to save the form for student. [attachment deleted by admin] Hi, I have a page with a PayPal button at the bottom. I am attempting to run two actions when the PayPal button is pressed. One is to process the PayPal payment and the other that opens another page which I have called testpage.php
I have used a script I found online as I have no experience in Javascript, this is meant to run two actions when the PayPal button is clicked. However only the testpage.php opens.
Here is what i got, have I done it wrong? Or is there a better way to do this?
<?php include 'init.php'; include 'includes/overall/header.php'; include 'includes/logo.php'; ?> <script language="Javascript"> <!-- function OnButton1() { document._xclick.action = "https://www.paypal.com/cgi-bin/webscr" // document._xclick.target = "_blank"; // Open in a new window document._xclick.submit(); // Submit the page return true; } function OnButton2() { document._xclick.action = "testpage.php" document._xclick.target = "_blank"; // Open in a new window // document._xclick.submit(); // Submit the page return true; } --> </script> <?php if (!isset($_SESSION['loggedin'])) { die("You must be logged in to view this page!"); //this causes to script to stop executing and lets the user know there is a problem /* Note: instead of the die() function, you could use the echo() function and provide an HTML link back to the login page, or use the header() function to just redirect users to the login page without any message. It is up to you to decide what your application should behave. */ } //else { //logged in elseif (isset($_SESSION['loggedin']) ){ //logged in $username = $_SESSION['loggedinuser']; $results = $con->query("SELECT * FROM user WHERE username = '$username';"); while($row = $results->fetch_array()) { $business = $row['paypal_email']; $user_id = $_GET['user_id']; $results1 = $con->query("SELECT * FROM live_sales WHERE user_id = '$user_id';"); while($row = $results1->fetch_array()) { $username = $row['username']; $fishtype = $row['fishtype']; $speciesCommon = $row['speciesCommon']; $speciesScientific = $row['speciesScientific']; $listing_title = $row['listing_title']; $age = $row['age']; $quantity = $row['quantity']; $origin = $row['origin']; $size = $row['size']; $environment = $row['environment']; $waterChemistry = $row['waterChemistry']; $temperature = $row['temperature']; $feeding = $row['feeding']; $sexing = $row['sexing']; $compatability = $row['compatability']; $temperament = $row['temperament']; $breeding = $row['breeding']; $comments = $row['comments']; $postage_type = $row['postage_type']; $postage_cost = $row['postage_cost']; $multipostage = $row['multipostage']; $cost = $row['cost']; echo "<div class='result'>"; echo "<h3>$speciesCommon</h3>"; echo "<h2>$listing_title</h2>"; echo "<ul class='results'>"; echo "<li>Species</li>" . str_replace("_"," "," $fishtype") . "<br>"; echo "<li>Common Name:</li> $speciesCommon<br>"; echo "<li>Scientific Name:</li> $speciesScientific<br>"; echo "<li>Age:</li> $age<br>"; echo "<li>Quantity:</li> $quantity<br>"; echo "<li>Price per item:</li> £$cost<br>"; echo "<li>Origin:</li> $origin<br>"; echo "<li>Size:</li>$size<br>"; echo "<li>Environment:</li> $environment<br>"; echo "<li>Water Chemistry</li> $waterChemistry<br>"; echo "<li>Temperatu </li> $temperature<br>"; echo "<li>Feeding:</li> $feeding<br>"; echo "<li>Sexing:</li> $sexing<br>"; echo "<li>Compatability:</li> $compatability<br>"; echo "<li>Temperament:</li> $temperament<br>"; echo "<li>Breeding:</li>$breeding<br>"; echo "<li>Comments:</li> $comments<br>"; echo "<li>Postage Type:</li>$postage_type<br>"; echo "<li>Postage Cost:</li> £$postage_cost $multipostage<br>"; ?> </ul> </div> <div align='center'> <form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <?php echo '<select name="quantity">'; echo "<option value='$quantity'>Maximum of $quantity available</option>"; for ($q=1; $q<=$quantity; $q++) { echo "<option value='$q'>$q</option>"; } echo '</select>'; if( $multipostage == "per item" ) { $postage_cost = $quantity * $postage_cost; } elseif( $multipostage == "Combined Postage" ) { $postage_cost; } ?> <br><br> <input type="hidden" name="shipping" value="<?php echo $postage_cost ?>"> <input type="hidden" name="business" value="<?php echo $business ?>"> <input type="hidden" name="currency_code" value="GBP"> <input type="hidden" name="item_name" value="<?php echo $speciesCommon ?>"> <input type="hidden" name="amount" value="<?php echo $cost ?>"> <input type="image" src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" onclick="OnButton1(); OnButton2();" alt="PayPal – The safer, easier way to pay online." > <img alt="" align="center" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1"></form> </div> <?php exit(); } } echo 'Sorry but we could not find any results.'; } include 'includes/overall/footer.php'; ?>Any help is always appreciated aquaman I cant seem to get these two forms to basically work together.....I need this code(a form submit): Code: [Select] <?php // Where the file is going to be placed $target_path = "uploads/public/uploads/admin/u1p2l3o4a5d6s789/98437e10ec5605a849c3bd9641494560_/"; /* Add the original filename to our target path. Result is "uploads/filename.extension" */ $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!"; } ?> with this code: Code: [Select] <?php if(isset($_POST['save'])) { $event = $_POST['event']; $startdate = $_POST['startdate']; $enddate = $_POST['enddate']; $description = $_POST['description']; $location = $_POST['location']; $month = $_POST['month']; $title1 = $_POST['title1']; $title2 = $_POST['title2']; $title3 = $_POST['title3']; $title4 = $_POST['title4']; $title5 = $_POST['title5']; $title6 = $_POST['title6']; $title7 = $_POST['title7']; $title8 = $_POST['title8']; $date1 = $_POST['date1']; $date2 = $_POST['date2']; $date3 = $_POST['date3']; $date4 = $_POST['date4']; $date5 = $_POST['date5']; $date6 = $_POST['date6']; $date7 = $_POST['date7']; $date8 = $_POST['date8']; $subevent1 = $_POST['subevent1']; $subevent2 = $_POST['subevent2']; $subevent3 = $_POST['subevent3']; $subevent4 = $_POST['subevent4']; $subevent5 = $_POST['subevent5']; $subevent6 = $_POST['subevent5']; $subevent7 = $_POST['subevent6']; $subevent8 = $_POST['subevent7']; $price1 = $_POST['price1']; $price2 = $_POST['price2']; $price3 = $_POST['price3']; $price4 = $_POST['price4']; $price5 = $_POST['price5']; $price6 = $_POST['price6']; $price7 = $_POST['price7']; $price8 = $_POST['price8']; $month2 = $_POST['month2']; $month_num = $_POST['month_num']; $day = $_POST['day']; $year = $_POST['year']; $shutoff = $_POST['shutoff']; if(!get_magic_quotes_gpc()) { $event = addslashes($event); $startdate = addslashes($startdate); $enddate = addslashes($enddate); $description = addslashes($description); $location = addslashes($location); $month = addslashes($month); $title1 = addslashes($title1); $title2 = addslashes($title2); $title3 = addslashes($title3); $title4 = addslashes($title4); $title5 = addslashes($title5); $title6 = addslashes($title6); $title7 = addslashes($title7); $title8 = addslashes($title8); $date1 = addslashes($date1); $date2 = addslashes($date2); $date3 = addslashes($date3); $date4 = addslashes($date4); $date5 = addslashes($date5); $date6 = addslashes($date6); $date7 = addslashes($date7); $date8 = addslashes($date8); $subevent1 = addslashes($subevent1); $subevent2 = addslashes($subevent2); $subevent3 = addslashes($subevent3); $subevent4 = addslashes($subevent4); $subevent5 = addslashes($subevent5); $subevent6 = addslashes($subevent6); $subevent7 = addslashes($subevent7); $subevent8 = addslashes($subevent8); $price1 = addslashes($price1); $price2 = addslashes($price2); $price3 = addslashes($price3); $price4 = addslashes($price4); $price5 = addslashes($price5); $price6 = addslashes($price6); $price7 = addslashes($price7); $price8 = addslashes($price8); $month2 = addslashes($month2); $month_num = addslashes($month_num); $year = addslashes($year); $day = addslashes($day); } include 'config.php'; include 'opendb.php'; $query = "INSERT INTO Registration (event, startdate, enddate, description, location, month, title1, title2, title3, title4, title5, title6, title7, title8, date1, date2, date3, date4, date5, date6, date7, date8, subevent1, subevent2, subevent3, subevent4, subevent5, subevent6, subevent7, subevent8, price1, price2, price3, price4, price5, price6, price7, price8, month2, shutoff) VALUES ('$event', '$startdate', '$enddate', '$description', '$location', '$month', '$title1', '$title2', '$title3', '$title4', '$title5', '$title6', '$title7', '$title8', '$date1', '$date2', '$date3', '$date4', '$date5', '$date6', '$date7', '$date8', '$subevent1', '$subevent2', '$subevent3', '$subevent4', '$subevent5', '$subevent6', '$subevent7', '$subevent8', '$price1', '$price2', '$price3', '$price4', '$price5', '$price6', '$price7', '$price8', '$month2', '$shutoff')"; mysql_query($query) or die('Error, query failed'); include 'closedb.php'; echo "<pre>".print_r($_POST, true)."</pre>"; } ?> I tried this: Code: [Select] <?php if(isset($_POST['save'])) { $event = $_POST['event']; $startdate = $_POST['startdate']; $enddate = $_POST['enddate']; $description = $_POST['description']; $location = $_POST['location']; $month = $_POST['month']; $title1 = $_POST['title1']; $title2 = $_POST['title2']; $title3 = $_POST['title3']; $title4 = $_POST['title4']; $title5 = $_POST['title5']; $title6 = $_POST['title6']; $title7 = $_POST['title7']; $title8 = $_POST['title8']; $date1 = $_POST['date1']; $date2 = $_POST['date2']; $date3 = $_POST['date3']; $date4 = $_POST['date4']; $date5 = $_POST['date5']; $date6 = $_POST['date6']; $date7 = $_POST['date7']; $date8 = $_POST['date8']; $subevent1 = $_POST['subevent1']; $subevent2 = $_POST['subevent2']; $subevent3 = $_POST['subevent3']; $subevent4 = $_POST['subevent4']; $subevent5 = $_POST['subevent5']; $subevent6 = $_POST['subevent5']; $subevent7 = $_POST['subevent6']; $subevent8 = $_POST['subevent7']; $price1 = $_POST['price1']; $price2 = $_POST['price2']; $price3 = $_POST['price3']; $price4 = $_POST['price4']; $price5 = $_POST['price5']; $price6 = $_POST['price6']; $price7 = $_POST['price7']; $price8 = $_POST['price8']; $month2 = $_POST['month2']; $month_num = $_POST['month_num']; $day = $_POST['day']; $year = $_POST['year']; $shutoff = $_POST['shutoff']; if(!get_magic_quotes_gpc()) { $event = addslashes($event); $startdate = addslashes($startdate); $enddate = addslashes($enddate); $description = addslashes($description); $location = addslashes($location); $month = addslashes($month); $title1 = addslashes($title1); $title2 = addslashes($title2); $title3 = addslashes($title3); $title4 = addslashes($title4); $title5 = addslashes($title5); $title6 = addslashes($title6); $title7 = addslashes($title7); $title8 = addslashes($title8); $date1 = addslashes($date1); $date2 = addslashes($date2); $date3 = addslashes($date3); $date4 = addslashes($date4); $date5 = addslashes($date5); $date6 = addslashes($date6); $date7 = addslashes($date7); $date8 = addslashes($date8); $subevent1 = addslashes($subevent1); $subevent2 = addslashes($subevent2); $subevent3 = addslashes($subevent3); $subevent4 = addslashes($subevent4); $subevent5 = addslashes($subevent5); $subevent6 = addslashes($subevent6); $subevent7 = addslashes($subevent7); $subevent8 = addslashes($subevent8); $price1 = addslashes($price1); $price2 = addslashes($price2); $price3 = addslashes($price3); $price4 = addslashes($price4); $price5 = addslashes($price5); $price6 = addslashes($price6); $price7 = addslashes($price7); $price8 = addslashes($price8); $month2 = addslashes($month2); $month_num = addslashes($month_num); $year = addslashes($year); $day = addslashes($day); } include 'config.php'; include 'opendb.php'; $query = "INSERT INTO Registration (event, startdate, enddate, description, location, month, title1, title2, title3, title4, title5, title6, title7, title8, date1, date2, date3, date4, date5, date6, date7, date8, subevent1, subevent2, subevent3, subevent4, subevent5, subevent6, subevent7, subevent8, price1, price2, price3, price4, price5, price6, price7, price8, month2, shutoff) VALUES ('$event', '$startdate', '$enddate', '$description', '$location', '$month', '$title1', '$title2', '$title3', '$title4', '$title5', '$title6', '$title7', '$title8', '$date1', '$date2', '$date3', '$date4', '$date5', '$date6', '$date7', '$date8', '$subevent1', '$subevent2', '$subevent3', '$subevent4', '$subevent5', '$subevent6', '$subevent7', '$subevent8', '$price1', '$price2', '$price3', '$price4', '$price5', '$price6', '$price7', '$price8', '$month2', '$shutoff')"; mysql_query($query) or die('Error, query failed'); include 'closedb.php'; echo "<pre>".print_r($_POST, true)."</pre>"; $target_path = "uploads/public/uploads/admin/u1p2l3o4a5d6s789/98437e10ec5605a849c3bd9641494560_/"; /* Add the original filename to our target path. Result is "uploads/filename.extension" */ $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!"; } } ?>but it didn't work..... Hello, I have a .htaccess file set up to create directories and files based on my PHP variables. That's how it looks anyway. It's really just some URL rewriting. I'm looking to submit a form and use the code on the same page to handle the form via isset(). The problem is, however, that $_SERVER['PHP_SELF']; redirects me back to the original base/index.php page, while nothing gets submitted. I can sort of see why, but is there any way to overcome it? I could probably use the actual file and variable names, but that isn't very practical as I intend on using this code as a basis for a much larger scale. I'm not too fond of using external pages as sources for the form action either for the same reason. My intentions were to have everything handled on a single page. Also, feel free to post constructive criticism on how to improve the code. I'm rather new to PHP and will need all the help I can get. .htaccess code Code: [Select] RewriteRule base/([a-zA-Z]+)/$ base/index.php?cat=$1 RewriteRule base/([a-zA-Z]+)/([a-zA-Z0-9]+)\.php$ base/index.php?cat=$1&subcat=$2 index.php code Code: [Select] <html> <head> <title>Index</title> </head> <body> <?php $cat=$_GET['cat']; $subcat=$_GET['subcat']; if (isset($cat)){ if ($cat=='foo'){ if (isset($subcat)){ if($subcat=='bar'){ if (isset($_POST['submit'])) { echo 'Entry Submitted Successfully'; } else{ ?> <h1>Add an Entry</h1> <div> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <div> <span>Field:</span> <span><input type="text" size="15" /></span> </div> <div> <input name="submit" type="submit" value="Submit" /> </div> </form> </div> <p> <a href="/base/">Return to Base Page</a> </p> <?php } } else { echo 'Error: Not a valid sub-category.'; } } else { ?> <h1>Select an Option</h1> <ul> <li><a href="bar.php">Add Entry</a></li> </ul> <p> <a href="/base/">Return to Base Page</a> </p> <?php } } else { echo 'Error: Not a valid Category.'; } } else{ ?> <h1>Base Page</h1> <h2><a href="foo/">Go to "Select an Option" page</a></h2> <ul> <li><a href="foo/bar.php">Go to "Add an Entry" page</a></li> </ul> <?php } ?> </div> </body></html> Hey guys, I'll be the first to say that I'm a real php n00b, and only understand the basics. I have a website already in place that someone else coded and I just need to add something to. There's a form that posts to another page and then back to a sql database. What I want to do is have the form also email me the contents of the form when it is submitted. Is there a way to have a form do multiple actions? I'm not sure the best way to go about this, so if someone has some pointers, I'd really appreciate it. Thanks! I don't have any PHP skills at all. In fact I'm probably looking for a script that can help accomplish what I'm asking about. Regardless, I'm having a hard time getting any answers or solutions to this. I would like to make a web form that collects cc#'s from my customers that is PCI Compliant in as simple a manner as possible. 99% of the time my clients are not being charged at all, and the cc is used simply to ensure a service is confirmed. If they were to be charged, I would have to do that manually as no payment gateways currently deposit into banks in the country I am in. One thought I had would be if I could have the cc# either split, or broken up into separate fields and emailed separately. I am told this is PCI Compliant. I would also be fine with the cc# being split between database and email. I know this is possible w/ zen cart, but I have been unable to find any scripts that do this and don't have a need for a shopping cart addition to my site. But, I am aware that zen cart and other shopping cart add ons have options for X's to cover a bunch of numbers in the middle of the string and write that directly to the database. One thing that is a necessity is that the majority of the data input to the form be emailed. So, I'm basically hoping to protect the cc data in the simplest way possible, which I thought would be to break it up. I'll be trashing the cc #'s once I get them. I have no need to file them. I do have a SSL on my server. I am completely open to other suggestions. Is something like this, or another option a possibility? My skills are rudimentary. I taught myself to write some html and also use Dreamweaver to subsidize for what I can't code myself. I apologize if this should be in one of the other forums. Hi, I am trying to get some charecters to display properly in emails that are sent via a form on my site. The finnish characters ä and ö come out as squares when viewed in Outlook. I have tried various encoding types such as UTF-8 and Western European (dreamweaver), both as the script encoding and as the encoding in the mail() function. $body = 'Sähköposti:' ; mail($salesEmail, "Call Back Request", $body, "MIME-Version: 1.0\r\nContent-type: text/html; charset=utf-8\r\nFrom: $salesEmail") ; = 'S�hk�posti:' or just squares in Outlook. I have also tried hard coding them as ä and ö and the symbol literals to no effect. Does anyone know what is causing this? Hi, Say I have the situation shown below: This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=321767.0 I created an app for my website, set action (read) and object (article), and placed the objects code (META tags in the head) at the article page on my website. Now, I want to know how to send a cUrl request whenever a user reads an article on my website, so it'll feature on his wall. When I press the "get code" link near the action, that's what I get: Code: [Select] curl -F 'access_token=***' \ -F 'article=http://example.com' \ 'https://graph.facebook.com/me/yellowheart:read' (There's an actual access token of course). Now, how do I make it happen? Daniel Im using dreamweaver, and I have a simple list menu that is linked to a dynamic source in my database. I cannot figure out how to create an action when they select something from the list menu. I suppose that it would have to be passed through the browser somehow. Im not very code fluent, but I try. If you know to accomplish this using dreamweaver cs4 or hard coding, I would appreciate it. I want this: When you click on an item it will bring up all the data pertaining to that particular record. My code: Code: [Select] <form id="form1" name="form1" method="post" action=""> <label for="customerlist">Select your customers</label> <p><label for="customers"></label> <select name="customers" id="customers"> <option value="None">None</option> <?php do { ?> <option value="<?php echo $row_Customers['name']?>"><?php echo $row_Customers['name']?></option> <?php } while ($row_Customers = mysql_fetch_assoc($Customers)); $rows = mysql_num_rows($Customers); if($rows > 0) { mysql_data_seek($Customers, 0); $row_Customers = mysql_fetch_assoc($Customers); } ?> </select> <input type="submit" name="Go" id="Go" value="Go" /> Hi Guys, I'm having some trouble running PHP scripts. I have two forms, each of which redirects to a PHP script (each PHP script is different, but essentially both have the same problem) as an action. The code is below. I'm hosted at Bluehost, which runs PHP on their servers so I know the tech is compatible. Thanks! Cheers! <html> <script type="text/php">include('newform.php');</script> <head> <title>TradeSquared></title> <p align="center">Trade Squared</p> </head> <body> <br> <br> <div align="center"> Create a new Listing: <form action="newform.php" method="get" name="newform"> Type:<select name="type"> <option value="book">Book</option> <option value="apt">Apartment</option> <option value="item">Class Items</option> </select> <input type="submit" value="Submit"/> </form> <br> Search current Listings: <form action="searchform.php" method="get" name="searchform"> Type:<select name="type"> <option value="book">Book</option> <option value="apt">Apartment</option> <option value="item">Class Items</option> </select> <input type="submit" value="Submit"/> </form> </div> </body> </html> This is the PHP code on which action redirects to <?php $type = $_GET=["type"]; if($type=="book") header("location:addbooklisting.html"); else if($type == "apt") header("location:aptform"); else header("location:itemform"); ?> Second page <html> <head> <title>Create New Book Listing</title> <p align="center"> <b>Create a New Book Listing</b> </p> </head> <body> <div align="center"> <br><br> <form name="addlisting" method="get" action="bookvalidation.php"> <table width="100" border="0" align="center"> <tr> <td align="center">Title </td> </tr> <tr> <td align="center"><input type="text" name="title"/> </td> </tr> <tr><td><p/></td></tr> <tr> <td align="center">Price </td> </tr> <tr> <td align="center">$<input type="text" name="dollars" size="3"/>.<input type="text" name="cents" size="2"/> </td> </tr> <tr><td><br></td></tr> <tr> <td align="center">ISBN</td> </tr> <tr> <td align="center"><input type="text" name="isbn"/></td> </tr> <tr><td><br></td></tr> <tr> <td align="center">Condition </td> </tr> <tr> <td align="center"><select name="cond"> <option name="used">Used</option> <option name="new">New</option> </select> </td> </tr> <tr><td><br></td></tr> <tr> <td align="center">Commentaries </td> </tr> <tr> <td align="center"><textarea rows="5" cols="30" name="comm"></textarea></td> </tr> <tr><td><br></td></tr> <tr> <td align="center"><input type="submit" value="Add Listing"/></td> </tr> </table> </form> </div> </body> </html> PHP code for second page <html> <head>Results</head> <body> The Following Occurred: <?php $title = $_GET["title"]; $dollar = $_GET["dollars"]; $cents = $_GET["cents"]; $price = $dollar.".".$cents $isbn = $_GET["isbn"]; $cond = $_GET["cond"]; $decide; $comments = $_GET["comm"]; for($i=0; $i<=12; i++) { if(ctype_digit($isbn)) $decide = true; else $decide = false; } if( !(($dollar && $cents)==int) ) echo "Price must be in numbers."; else if($decide == false || strlen($isbn)!=13) echo "ISBN contains 13 characters and must be numbers only" else { $db=mysql_connect("localhost","username","pass!"); mysql_select_db("db_dataabse",$db); $dbsucces=mysql_query("INSERT INTO BookListings (Title, ISBN, Price, Condition, Comments) VALUES ('$title', '$isbn', '$price', '$cond', '$comments')"); if($dbsuccess==true) echo "Posting was succesful"; else echo"Unsuccesful log."; } ?> </body> </html> On a website currently under development the URL does not change when navigating around on the page. It always displays the root URL. This is the script that should generate the links: $URLvars=substr($_SERVER["PHP_SELF"], strrpos($_SERVER["PHP_SELF"],"/")+1); $vatLink=$URLvars; $thisPageURL=$_SERVER["PHP_SELF"]; if(strpos($thisPageURL, "secure/locktech/")!==false)$thisPageURL=substr($_SERVER["PHP_SELF"], 16); $prodLink="http://www.lock-tech.co.uk".$thisPageURL; It used to. However, the server has changed and it does not any more. Is it maybe because the 2 paths (http://www.lock-tech.co.uk and secure/locktech/) must be changed according to the new server? Does anyone know what exactly do these paths stand for? I understand that one of them is the root path but what does the path in the line Code: [Select] if(strpos($thisPageURL, "secure/locktech/")!==false)$thisPageURL=substr($_SERVER["PHP_SELF"], 16); stand for? I'm trying to generate RSS by using PHP and MySQL but I keep getting an error message that I don't know how to solve. Here's the error message: <b>Deprecated</b>: Function mysql_db_query() is deprecated in <b>G:\xampp\htdocs\xampp\dsa\class_rss.php</b> on line <b>32 Here's line 32: Code: [Select] $result = mysql_db_query (DB_NAME, $query, LINK); Here's the entire code from the class: Code: [Select] <? // code followed from http://www.webreference.com/authoring/languages/xml/rss/custom_feeds/ // images sourced: http://www.inyourbasket.com/search/usb-flash-drives/09A?cm_mmc_o=7BBTkw*Vzbp+mwzygt*JmP+4wFByY+mfbgLl*JmP+4wFByY+mfbgL+C+7wEwybg&gclid=CKuGh8DwyKcCFYFB4QodyGRvBg class RSS { // function to include the file which holds global variables. public function RSS() { require_once ('connectvars.php'); } // function derived from both private functions. public function GetFeed() { return $this->getDetails() . $this->getItems(); } // function to connect to the database private function dbConnect() { DEFINE ('LINK', mysql_connect (DB_HOST, DB_USER, DB_PASSWORD)); } // function to retreive data from the table, and insert between set xml tags which loops through the rows in the table. private function getDetails() { $stick = "stick,"; $location = "location,"; $identification = "identification"; $this->dbConnect($stick, $location, $identification); $query = "SELECT * FROM ". $stick . $location . $identification; $result = mysql_db_query (DB_NAME, $query, LINK); while($row = mysql_fetch_array($result)) { $details = '<?xml version="1.0" encoding="ISO-8859-1" ?> <rss version="2.0"> <channel> <title>'. $row['stick.make'] .'</title> <description>'. $row['stick.colour'] . $row['location.street'] . $row['location.town'] . $row['location.city'] .'</description> <image> <url>'. $row['identification.image_url'] .'</url> <width>'. $row['identification.image_width'] .'</width> <height>'. $row['identification.image_height'] .'</height> </image>'; } return $details; } // function to iterate through the table, retreiving data each time and outputting an end result of an RSS structured page. private function getItems() { $stick = "stick,"; $location = "location,"; $identification = "identification"; $this->dbConnect($stick, $location, $identification); $query = "SELECT * FROM ". $stick . $location . $identification; $result = mysql_db_query (DB_NAME, $query, LINK); $items = ''; while($row = mysql_fetch_array($result)) { $items .= '<item> <title>'. $row["stick.make"] .'</title> <description><![CDATA['. $row["stick.colour"] .']]></description> </item>'; } $items .= '</channel> </rss>'; return $items; } } ?> Could anyone help me out here? Thanks I have something like this on one of my pages: $name = 'Bob'; Code: [Select] if ((isset($_POST['name'])) || ($_POST['name'] == '')) { $name = $_POST['name']; //update database } echo '<form action='' method='POST'>'; echo '<table><tr><td width="125">Name: </td><td><input type="text" name="signature" style="width: 270px;" value="' . $name . '" /></td></tr></table>'; echo '</form>'; Here's the problem: Initially, because the form data has not been sent the input box says: 'Bob'. If I remove the name Bob from the input box by manually clicking in it and deleting the name, and I submit the form, it keeps showing 'Bob', whereas I would like it to be empty. What am I doing wrong? I currently have a query that compiles a League Standings Table (the full code is below) and generate the ranking with Code: [Select] @rownum := @rownum+1 AS rank This works fine for the main standings page but I want to use the row numbers elsewhere. Each team has it's own page which uses 'team.team_id' as its 'recordID'. On these pages I would like to show that particular teams ranking in the standings. The two options I see would be to run the query filtering by 'team.team_id' but that would only return the one record so ranking would always be '1' or run the whole query and then somehow find which ranking relates to 'team.team_id' (something that may be possible with VIEWS but the database is running on MySQL4) but I cannot figure out how to get around this. For example, if the standings were Rank Team 1 Rovers 2 United 3 City 4 Rangers 5 Town 6 Athletic 7 Wanderers 8 Hotspur On the 'Rangers' page I would want it to show 'RANKING: 4' and on the 'Athletic' page it would show 'RANKING: 6'. On top of this I would want to show a small version of the rankings with one team above and one team below (it would actually be two teams but I will keep it simple until I understand it!) so one again given the two examples above I would get RANGERS PAGE Rank Team 3 City 4 Rangers 5 Town ATHLETIC PAGE Rank Team 5 Town 6 Athletic 7 Wanderers The query is $i = 1; $ht = "g.home_team = t.team_id"; $at = "g.away_team = t.team_id"; $hw = "g.home_goals > g.away_goals"; $aw = "g.home_goals < g.away_goals"; $d = "g.home_goals = g.away_goals"; $hg ="g.home_goals"; $ag ="g.away_goals"; $table = mysql_query("SELECT t.team_name as Tm, @rownum := @rownum+1 AS rank , (sum(CASE WHEN (".$ht." AND ".$hw.")OR(".$at." AND ".$aw.") THEN 3 ELSE 0 END) + sum(CASE WHEN (".$ht." OR ".$at.") AND ".$d." THEN 1 ELSE 0 END)) AS P , (sum(CASE WHEN (".$ht." AND ".$hw.") THEN 3 ELSE 0 END) + sum(CASE WHEN (".$ht.") AND ".$d." THEN 1 ELSE 0 END)) AS HP , (sum(CASE WHEN (".$at." AND ".$aw.") THEN 3 ELSE 0 END) + sum(CASE WHEN (".$at.") AND ".$d." THEN 1 ELSE 0 END)) AS AP , count(CASE WHEN (".$ht." OR ".$at.") THEN 1 ELSE 0 END) as GP , sum(CASE WHEN (".$ht." ) THEN 1 ELSE 0 END) as HGP , sum(CASE WHEN ".$at." THEN 1 ELSE 0 END) as AGP , sum(CASE WHEN (".$ht." AND ".$hw.") OR (".$at." AND ".$aw.") THEN 1 ELSE 0 END) AS W , sum(CASE WHEN (".$ht." AND ".$hw.") THEN 1 ELSE 0 END) AS HW , sum(CASE WHEN (".$at." AND ".$aw.") THEN 1 ELSE 0 END) AS AW , sum(CASE WHEN (".$ht." AND ".$d.") OR (".$at." AND ".$d.") THEN 1 ELSE 0 END) AS D , sum(CASE WHEN (".$ht." AND ".$d.") THEN 1 ELSE 0 END) AS HD , sum(CASE WHEN (".$at." AND ".$d.") THEN 1 ELSE 0 END) AS AD , sum(CASE WHEN (".$ht." AND ".$aw.") OR (".$at." AND ".$hw.") THEN 1 ELSE 0 END) AS L , sum(CASE WHEN (".$ht." AND ".$aw.") THEN 1 ELSE 0 END) AS HL , sum(CASE WHEN (".$at." AND ".$hw.") THEN 1 ELSE 0 END) AS AL , SUM(CASE WHEN (".$ht.") THEN ".$hg." WHEN (".$at.") THEN ".$ag." END) as GF , SUM(CASE WHEN (".$ht.") THEN ".$hg." END) as HGF , SUM(CASE WHEN (".$at.") THEN ".$ag." END) as AGF , SUM(CASE WHEN (".$ht.") THEN ".$ag." WHEN (".$at.") THEN ".$hg." END) as GA , SUM(CASE WHEN (".$ht.") THEN ".$ag." END) as HGA , SUM(CASE WHEN (".$at.") THEN ".$hg." END) as AGA , (SUM(CASE WHEN (".$ht.") THEN ".$hg." WHEN (".$at.") THEN ".$ag." END) - SUM(CASE WHEN (".$ht.") THEN ".$ag." WHEN (".$at.") THEN ".$hg." END)) as GD , (SUM(CASE WHEN (".$ht.") THEN ".$hg." END) - SUM(CASE WHEN (".$ht.") THEN ".$ag." END)) as HGD , (SUM(CASE WHEN (".$at.") THEN ".$ag." END) - SUM(CASE WHEN (".$at.") THEN ".$hg." END)) as AGD from teams t left join all_games g on t.team_id in (g.home_team,g.away_team) WHERE comp = '1' AND home_goals IS NOT NULL AND date BETWEEN '2010-07-01' AND '2011-06-31' GROUP BY t.team_id ORDER BY P desc, GD desc, GF desc The html is Code: [Select] <table width="" border="0" cellpadding="0" cellspacing="0" BORDER=1 RULES=ROWS FRAME=BOX> <tr> <td></td><td></td> <td colspan="9" align="center" bgcolor="#00FF99">ALL</td> <td colspan="9" align="center" >Home</td> <td colspan="9" align="center">Away</td> </tr> <tr> <td class="hdcell" >POS</td> <td class="hdcell" >Team</td> <td width="30" class="hdcell">P</td> <td width="30" class="hdcell">W</td> <td width="30" class="hdcell">D</td> <td width="30" class="hdcell">L</td> <td width="30" class="hdcell">F</td> <td width="30" class="hdcell">A</td> <td width="30" class="hdcell">GD</td> <td width="30" class="hdcell">Pts</td> <td width="30" class="hdcell"></td> <td></td> <td width="30" class="hdcell">P</td> <td width="30" class="hdcell">W</td> <td width="30" class="hdcell">D</td> <td width="30" class="hdcell">L</td> <td width="30" class="hdcell">F</td> <td width="30" class="hdcell">A</td> <td width="30" class="hdcell">GD</td> <td width="30" class="hdcell">Pts</td> <td></td> <td width="30" class="hdcell">P</td> <td width="30" class="hdcell">W</td> <td width="30" class="hdcell">D</td> <td width="30" class="hdcell">L</td> <td width="30" class="hdcell">F</td> <td width="30" class="hdcell">A</td> <td width="30" class="hdcell">GD</td> <td width="30" class="hdcell">Pts</td> </tr> <?php while ($row_table = mysql_fetch_assoc($table)){ echo '<tr> <td style="text-align:left" width="30">'.$i.'</td>'; echo '<td style="text-align:left">'.$row_table['Tm'].'</td> <td style="text-align:left">'.$row_table['GP'].'</td> <td style="text-align:left">'.$row_table['W'].'</td> <td style="text-align:left"> '.$row_table['D'].'</td> <td style="text-align:left"> '.$row_table['L']. '</td> <td style="text-align:left"> '.$row_table['GF']. '</td> <td style="text-align:left"> '.$row_table['GA']. '</td> <td style="text-align:left"> '.$row_table['GD']. '</td> <td style="text-align:left"> '.$row_table['P']. '</td> <td style="text-align:left"></td> <td style="text-align:left"></td> <td style="text-align:left">'.$row_table['HGP'].'</td> <td style="text-align:left">'.$row_table['HW'].'</td> <td style="text-align:left">'.$row_table['HD'].'</td> <td style="text-align:left"> '.$row_table['HL']. '</td> <td style="text-align:left"> '.$row_table['HGF']. '</td> <td style="text-align:left"> '.$row_table['HGA']. '</td> <td style="text-align:left"> '.$row_table['HGD']. '</td> <td style="text-align:left"> '.$row_table['HP']. '</td> <td style="text-align:left"></td> <td style="text-align:left">'.$row_table['AGP'].'</td> <td style="text-align:left">'.$row_table['AW'].'</td> <td style="text-align:left">'.$row_table['AD'].'</td> <td style="text-align:left"> '.$row_table['AL']. '</td> <td style="text-align:left"> '.$row_table['AGF']. '</td> <td style="text-align:left"> '.$row_table['AGA']. '</td> <td style="text-align:left"> '.$row_table['AGD']. '</td> <td style="text-align:left"> '.$row_table['AP']. '</td> </tr>'; $i++; } ?> </table> As always, thanks in advance for any tips or suggestions, even if they are telling me to scrap what I have so far and start again!! Steve PS. Can someone explain why @rownum := @rownum+1 AS rank causes $i to increment by one? I found the code while searching and do not understand why $i is necessary unless it is a reserved reference. The way the code looks, I should be able to output the ranking using 'rank' but that does not work. I have no problem with how it does things, it would just be nice to understand! Hi, I have a question here. Currently my $tutor_id is auto incremental in my SQL, and it is in running numbers. However I will like to add a 'T' in front of the id. Example: Currently, our id number is 1 2 3 4 etc. Would like to achieve T1 T2 T3 T4 etc. How do I do it? Below is my code as well. Please kindly advise. Thanks /**INSERT into tutor_id table to create a new id for new tutors**/ $query = "INSERT INTO tutor_id (id) " . "VALUES ('$id')"; $results = mysqli_query($dbc, $query) or die(mysqli_error()); $tutor_id = mysqli_insert_id($dbc); /**INSERT into tutor table**/ $query1 = "INSERT INTO tutor (tutor_id, email) " . "VALUES ('$tutor_id', '$email')"; $results1 = mysqli_query($dbc, $query1) or die(mysqli_error()); I'm not sure of the appropriate subject line for this feature, but hopefully I'm close. I'll try to describe what I'm trying to do. The most common place you see this is on web based file uploads so I'll use it as my example. Let's say I want to allow my user to upload files so there is a text box where they enter the file name. The user is allowed to upload as many files as he wants with 1 push of the submit button. Upon the loading of the form, there will be 5 textboxes for file upload, but if the user wants to upload more than 5 files, there is a link that is clicked and I think via ajax or javascript another textbox will be added. The user can do this for as many files he wants to upload. This is what it looks like to the user, but then when the form is submitted how are these variables referenced? So how is this setup in the main form and how are the variables referenced after form submission? If anyone can point me to a good web tutorial on this type of thing I would appreciate it. Thanks Carl Hi. I have a rating site where users fill in a name of what they are rating, comments about it and a rating and submit it to my database. I then have another page which shows all of these entries but only the name and overall rating using php. What I want is for users to click on the name and it take them to a separate page which displays all the comments and ratings for that item. As users can add items to rate I cant set up a page for each manually so was wondering how to do it dynamically. Everything i throw into google leads me in the wrong direction though. If someone could point me to a good tutorial or give me an idea about what to search id be very grateful. Cheers. Hey all, I have a relationship where a zone has many posts and a category has many zones but a zone can also have many categories. The zones are basically parts of a page, such as the main area and sidepanel stored in database as records with name fields such as 'panel' and 'main'. There's a serious flaw right now and I would like to know the best solution to address it. Right now I access the posts of a zone of a category like this: Code: [Select] $category->zone->get()->post->get(); The above ends up displaying all the posts in the database for any given category because when category is selected, it searches for the associating zones, and then selects all posts related to those zones, which is wrong. i want to select all posts of the zones associated with that particular category. Current database: Code: [Select] posts id zone_id zones id name categories_zones id zone_id category_id categories id What should I do? Add a category_id column to the posts table and relate the post directly to the category as well as directly to the zones table so the post table would have two foreign keys: category_id and zone_id Would this be the most effective thing to do given my requirements? Thanks for response. |