Jump to content

GingerRobot

Staff Alumni
  • Posts

    4,082
  • Joined

  • Last visited

Everything posted by GingerRobot

  1. The mysort() function is what defines the user sort. This function must expect the first two parameters passed to it to be two different elements from the array you are sorting. The variable names $a and $b are just arbitrary names - they are the ones used on the php site for this function, so it's stuck with me. The user sort should return a value, which tells the usort() function how to order the two elements. If the first element is 'less than' the second, it should return a negative number. If the elements are equal, 0 should be returned. If the first is 'more' than the second, a positive number should be returned. That is what the return statement deals with. I seem to be babbling, perhaps a read through the manual could help: www.php.net/usort As for: echo '<a href="viewbook.php?id='.$k.'">'.$n.'# '.$v[0].' with rank: '.number_format($v[1])."</a><br />\n"; This obviously echos the links. $ranks is a multidimensional array. Each element is an array in itself, with the first element as the title of the book (key 0) and the second element as the rank number (key 1). So, our foreach loop works through each element of $rank, with each value being an array. So we echo $v[0] to get the title, and $v[1] to get the rank. Hope that clears some of it up. If not, let me know and ill see if i can explain more. Edit: Perhaps i should have explained these two questions the other way around; Since $ranks is a multidimensional array (which i explained in the second part) we need the usort() function (which was the first question). In ordering the elements of $rank, which are arrays in themselves, it must look at the ranking, which has a key of 1.
  2. I've also never worked with paypal. But since you pass a success url variable to them, could you not stick the information you want back on the end of that, and retrieve it from the $_GET array? e.g: $paypal['success_url'] = "thankyou.php?orderno=$orderno";
  3. Trust me, your personnal internet connection does have a limit. I guarantee that if you check the TOS you will find a fair use policy. There are an awful lot of companies, hosting and ISP alike, that go around with unlimited this or that, but have a fair use clause, with an unspecified limit. Which turns out to be very low. That said, there are also lots of companies offering unlimited this or that, which also have a fair use clause, but their limit is high.
  4. See here for a discussion on PHP and web design books.
  5. That wouldn't help. Try: foreach($_POST['interests'] as $value) { echo "<li>$value</li>\n"; } You shouldn't have had the $sign in there. interpim: FYI: text inside single quotes isn't parsed. If you want a variable to be echoed , you must place it inside double quotes, or no quotes at all. With that code, the text $value would literally be displayed.
  6. There is no key used in the array on this line: if ($el[] >= $wal) { // error on this line. Since the only field you pull from the database is Mothership, i assume that was meant to be: if ($el['Mothership'] >= $wal) { // error on this line.
  7. You'll need to go through and change the various fields. You'll also need to modify the existing mysql database. Basically: you need to find everywhere that name is used, and split it into title, firstname and lastname; modify zip to postcode; and remove state.
  8. No problem. Could you mark this topic as solved please?
  9. In other words, you're supposed to validate the output (i.e. the HTML) not the PHP.
  10. Yeah, but the data would then not get inserted into the database.
  11. Its not the line, its the entire insert_order() function.
  12. So it's all working, we just need to add in the redirect? Try: <?php # vim:ft=php: if (!$_SESSION['up_files']) header('Location: index.php?page=comp'); $_PAGE['color'] = 'orange'; if ($_POST['xx'] == 'ctx') { $body = 'The Competition Entry form was submitted on: ' . date('F j, Y, g:i a') . ' by ' . $_POST['email'] . ' at IP: ' . $_SERVER['REMOTE_ADDR']; if ($_SERVER['HTTP_VIA']) { $via = explode(' ',$_SERVER['HTTP_VIA']); $body .= ' (via ' . $via[1] . ')'; } if ($_SERVER['HTTP_X_FORWARDED_FOR']){ $body .= ' [Forwarded For: ' . $_SERVER['HTTP_X_FORWARDED_FOR'] . ']'; } $body .= "\n\nDetails:\n\n" . $_POST['fname'] . ' ' . $_POST['lname'] . "\n" . $_POST['email'] . "\n" . $_POST['phone'] . "\n" . "\n\nPicture Details:\n\n" . $_POST['info'] . "\n\nFile Details:\n\n" . print_r($_SESSION['up_files'],true) . "\n\n"; if(mail('xxxxxxx@xxx.com','xxxxxxxxxxx',$body)){ header("location:thankyou.php"); }else{ echo 'Email could not be sent!'; } } ?> <div class="indented"> <strong>Your Details</strong><br /><br /> <form method="post"> <input type="hidden" name="xx" value="ctx" /> <table> <tr> <td class="ordertbl">First Name:</td> <td class="ordertbl"><input type="text" name="fname" value="<?= $_SESSION['fname'] ?>" /></td> </tr> <tr> <td class="ordertbl">Last Name:</td> <td class="ordertbl"><input type="text" name="lname" value="<?= $_SESSION['lname'] ?>" /></td> </tr> <tr> <td class="ordertbl">E-Mail Address:</td> <td class="ordertbl"><input type="text" name="email" value="<?= $_SESSION['email'] ?>" /></td> </tr> <tr> <td class="ordertbl">Phone Number:</td> <td class="ordertbl"><input type="text" name="phone" value="<?= $_SESSION['phone'] ?>" /></td> </tr> <tr> <td class="ordertbl">Information on the picture (location, settings etc) </td> <td class="ordertbl"><input type="text" name="info" value="<?= $_SESSION['info'] ?>" /></td> </tr> <br /> <strong>Review your Entry</strong> <br /> <br /> <?php $i = 0; foreach ($_SESSION['up_files'] as $imgrec) { echo "<li id=\"imgli$i\"><img alt=\""; echo $imgrec['name'] . "\" src=\"upload/"; echo basename($imgrec['new_path']) . "\" width=\"170\" height=\"120\"/></li>\n\n"; $i++; } ?> <tr><td colspan="2"> </td></tr> <tr><td colspan="2"><span style="margin-left: 150px;"><input type="submit" value="Send Entry" style="margin-left: 230px;" />Note - click only once!</span></td></tr> <tr></tr> </table> </form> </div> One more request, try and use full php opening tags(<?php) when you post your code here, syntax highlighting makes things much easier to read.
  13. No, we're just not going to bother to help you until you bother to enclose your code inside tags so we can actually read it. p.s. Your problem is more important than other people's because?
  14. With that little code, it's hard to help you. However, you still need to have the form submit to the place where the processing is done - e.g. where the email is sent. It's no good having the form submit straight to the thankyou page, otherwise the email wont ever get sent. You need to submit your form to whichever page sends the email, and add on a header redirect once the email is sent: //once email is sent: header("location:thankyoupage.php"); p.s, try to remember to enclose your code inside tags (without the spaces) it's much more readable! Oh, and welcome to the site
  15. When i run that page through the validator, there are 6 errors shown for me, all of which relate to input fields missing a containing element.
  16. There is nothing wrong with that line, apart from that fact it's hideously unreadable. Not the OP fault either, it's reproduced from a book. The reason for the error message is actually that insert_order($_POST) is evaluating to false, for whatever reason. Edit: Just looking at the function, insert_order() (i have the book that this code has come from). It looks like you're going to have to modify that a fair bit to make it work with the additional fields you've added. I would imagine that one of the queries is failing somewhere along the line, causing the function to return false.
  17. You'll need AJAX for that. Take a look here for some tutorials: http://www.ajaxfreaks.com/tutorials.php The basic principle will that you will call the javascript request function (which is given in the above tutorials) using the onChange attribute of the drop down box. You'll pass along the city code of the selected city to a separate php page, which will query the database, and return the relevant information. The javascript can then update part of your form with whatever your searching for.
  18. You'll want to turn the the list into a list of links. You can then pass along a variable to identify the particular row in the database - hopefully you have a unique ID that can be used. So, to display the list, you'll have something along the lines of: <?php //you should already have something which looks at least similar to this $sql = "SELECT `id`,`otherfield` FROM `yourtable`"; $result = mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_assoc($sql)){ echo '<a href="viewdetails.php?id='.$row['id'].'">'.$row['otherfield']."</a><br />\n"; } ?> Which links to a page, viewdetails.php, which would look similar to: <?php $id = (int) $_GET['id']; $sql = "SELECT * FROM `yourtable` WHERE `id`=$id"; $result = mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_assoc($result); //display other information ?> Of course, you may wish to display the information on the same page as the list. If you were wanting to do this without reloading the page, then you should look into AJAX.
  19. There appears to be a stray 'AND' in there. Try: $query = "SELECT * FROM cmads WHERE (keyw LIKE '%$trimmed%' OR buzzname LIKE '%$trimmed%' OR descr LIKE '%$trimmed%' OR sub LIKE '%$trimmed%') AND (region LIKE '$region') ORDER BY keyw"; $numresults=mysql_query($query) or die(mysql_error().'<br />Query'.$query); $numrows=mysql_num_rows($numresults); I've also added an or die statement to the query - it'll show us the mysql error if there is one.
  20. You misunderstand me. What happens if I want contact us to be a heading AND a link?
  21. Try: <?php $number = $_POST['UserMobile']; if(ereg("^07[0-9]{9}$",$number)){ $mobile = $number; } ?>
  22. How's about: <?php $valid_referers = array('yoursite.com','someothersite.com',''); if(!in_array($_SERVER['HTTP_REFERER'],$valid_referers)){ echo 'Invalid Referer'; exit; } ?> Im using the $_SERVER superglobal array rather than the getenv() function, since this is what it was created for. Couple of things to note though: 1.) The HTTP referer is unrealiable at best. It can be faked. It is not sent by all browsers. Some filewalls prevent it. 2.) I've included one of the valid referes as a blank; there will be no HTTP referer sent if a user navigates directly to your website - this, of course, should also aleviate the problems caused by browsers and firewalls not sending this. 3.) For the above reasons, HTTP referer shouldn't be relied upon as a security tool - ligitimate users will find themselves blocked; illigitimate users will find a way round it.
  23. One thing i would notice is that it doesn't appear to give you the functionality of having say, Contact Us lead to contactus.php AND to have Contact Us as an array with sub links such as FAQs, Email Us etc which is quite commonly used on menus.
  24. The problem is that if there are tags in the text, the browser believes they are HTML tags, and gets confused. You need to use the htmlentities() function. It will change tags,quotes,symbols etc to their relevant HTML character code.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.