Jump to content

cags

Staff Alumni
  • Posts

    3,217
  • Joined

  • Last visited

Everything posted by cags

  1. I'd have to concur with lemmin, I think you'll find they all fail. I'm guessing all the variables at the top of register.php should be $_POST not $_SESSION. Also assuming that is right, quick tip. I don't believe $_POST['First Name'] will be valid, I think it will have automatically been converted to $_POST['First_Name'].
  2. How about? <?php if(preg_match("/^[a-z]*$/i", $first_name)) { //all alphabetic chars } ?>
  3. <?php $text = "http://site1.com/mylink.html\nhttp://site2.com/newlink"; $str = explode("\n", $text); foreach($str as $k=>$v) { $sql = "INSERT INTO `table` (`url`, `domain`) VALUES ('".$v."','".parse_url($v, PHP_URL_HOST)."')"; echo $sql . '<br/>'; } ?>
  4. SELECT (`col1` + `col2` + `col3` + `col4` + `col5` + `col6` + `col7` + `col8` + `col9`) /18 AS `average` FROM `table` WHERE `id`=5
  5. The only time $variables exist on a form is between the time the user requests that page and the time the PHP parser has finished processing your page. After that point if you have not stored the value in some manner that would allow it to persist the value is lost. <?php if($_REQUEST['command']=='Add') { $pass=$_REQUEST['txtPass']; $pass2=$_REQUEST['txtPass2']; /* At this point you must either: echo $pass back into a hidden input on a form, so the next time the user clicks submit it still exists. store it in a variable that does persist (such as the $_SESSION superglobal array) store it in a flat file system store it in a database */ ?> It's very different to working with a .NET desktop application. In that situation obviously you have access to any variables in scope at all times. With PHP there is no ability to work in that way with the site being a multi-user experience obviously single instances of $variables become irrelevant. The most similar likeness is the $_SESSION array which allows you to store information for each individual on the site. Handling events on input items I believe it possible but it's JavaScript related and alas I know nothing about JavaScript.
  6. I just don't see that you would gain anything, you can play with your localhost settings all you like to get to grips with Apache and PHP. If you want your site online that's fine too, but why not just use a free webhost such as 000webhosts to host your file. Then you don't need to worry about your IP or anything. Just my opinion though.
  7. Still not seeing the problem.... <?php if($_SERVER['HTTP_REFERER'] != "http://www.google.com") { header("Location: http://www.yahoo.com"); exit(); } ?> <!-- all the HTML in the world can go here -->
  8. It doesn't sound like your obvjective should be that difficult, I think nobody has replied because to myself at least I really don't understand what your description. Perhaps it would help if you clue'd us in to what exactly your database table looks like?
  9. Certainly it's possible using a service such as the one PFMaBiSmAd suggests, but I must admit I'd struggle to find enough pro's to outweigh the con's of hosting your own site on your own PC.
  10. Well lets put it this way, you said they have to upload two files, you can't store them as the same filename can you? They'd overwrite each other. Without getting impatient with me, I did read the code and understood that their was "&" their but I really have got no idea what to put in its place. If you don't understand what character should be there you really need to go back to basics and learn PHP, otherwise your going to be doing absolutely nothing but posting problems on here, and it won't take long for people to become impatient. Many of the questions your asking are far beyond what I'd consider the difficultly of knowing what that character should be. If you don't get the basics like that down, your unlikely to get anywhere without people essentially spoon feeding code to you. As tempted as I am to not tell you what it should be, I guess I will this once. sql is a variable, all variables in PHP must begin with a dollar sign. I'm sorry if any of that sounds too harsh, thats not my intention, I'm just pointing out that knowing a variable should begin with a dollar sign should be one of the first things you learnt.
  11. So you wish to store the selected value in a variable? In order to do that the form would need to be submitted (PHP is server side, so it can only see the selected value once you submit the information back to the server). You would then use either the $_POST or $_GET superglobal arrays to fetch the value based on the name attribute of the select node.
  12. You can test it locally regardless of your IP changing. All you need to do is install Apache and PHP (plus any other tech you require like MySQL). In order to access the site you can then use the loopback address (aka Localhost address) of 127.0.0.1. If you wish it to be accessable to other from outside your computer the dynamic IP would be a bad thing, but that really wouldn't be a good idea. You would need to get a webhost to do the work for you.
  13. What do you mean by... Surely it would just be something along the lines of... <?php if($_SERVER['HTTP_REFERER'] != "http://www.google.com") { header("Location: http://www.yahoo.com"); } ?> Unless I'm missing something?
  14. Firstly the first problem is fairly obvious if you actually read the error message. Unexpected ampersand, so we look through the line for an ampersand, oooh, look one right at the start. Hmm.. thats a variable, I wonder what character that should be.... Secondly, no that doesn't make any sense. If you want to move both files, and one file input node has the name upload and the other has the name upload 1, then you would be more along the lines of... if(move_uploaded_file($_FILES['upload']['tmp_name'], $target) && move_uploaded_file($_FILES['upload1']['tmp_name'], $target2)) { } That may not be 100% I've not worked with files in months.
  15. You are using $_REQUEST['starting_year'] without checking isset that could potentially cause an undefine index error. You would also get the error if the value of $_REQUEST['starting_year_d'] is not eq, gt, lt, neq, gte or lte.
  16. I'm begining to think people don't actually read my posts. You say you've tried two lines of code, but not once did you try the code I actually suggested. I'll say it one more time. The objective of nl2br is to convert the \n characters in your string to <br />. What you want to do is remove the \n's from the end of your text before converting the remainding \n's to <br /> in order to get them to display correctly in HTML. <?php nl2br(stripslashes(rtrim($case))) ?>
  17. nl2br turns \n characters into the <br/> so if you call rtrim() before calling nl2br it should work fine. <?php nl2br(stripslashes(rtrim($case))) ?>
  18. I'm not sure I understand. Your description sounds like you want this? <?php $textareaname = str_replace("http://", "", $_POST['links']); $str = explode("\n", $textareaname); foreach($str as $url) { echo $url . '<br />'; } ?>
  19. I don't see how it's better. Browsershots is a different kettle of fish altogther. It simply generates an image of a single page as it would appear in dozens of different browsers. That is (IMHO) in no way the same as ietester, which is an actual functioning browser that allows you to change 'compatibility mode' between different versions of IE.
  20. You're whole process doesn't make sense (to me). Look at it in a work-flow sort of way. User requests page. Page is output (at this point <input="hidden" name="decription" ... will have a value of "" because $description isn't set yet) User fills in form User clicks submit Code replaces spaces with underscores Code inserts into database Page is output (at this point <input="hidden" name="description" ... will have a value of the previous form) As you can see the value included in the hidden input is at no point relevant to what is input to the form... Or am I missing something? If you want both an underscored version and a non underscored version in the database, surely you should just be doing... <?php $filename = $_POST['filename']; $under_filename = str_replace("_", " ", $filename); mysql_query("INSERT INTO `table` (`filename`, `under_filename`) VALUES ('$filename', '$under_filename')"); ?>
  21. Entirely depends on your database and HTML but a basic example is something along the lines of... $sql = " SELECT * FROM `table` WHERE `state`='". $_POST['state'] . "' AND `City` LIKE '%" . $_POST['city'] . "%' AND `gender`='" . $_POST['gender'] . "' AND `ethnicity`='" . $_POST['ethinicity'] . "'"; Age Range will depend on how you store the ranges in the dropdown and how you store the ages in the database, you might well have to set up a switch statement/if block. Interested in will also depend how it's kept in the database.
  22. So I take it you didn't write the code. <form action="" method="post"> <?php make_calendar_pulldowns2() ?> </form> <?php if(checkdate($_POST['year2'] . "-" . $_POST['month2'] . "-" . $_POST['day2'])) { echo "Valid"; } ?> Change part 1 to the following will stop the values reseting on submit. <form action="" method="post"> <?php make_calendar_pulldowns2($_POST['month2'], $_POST['day2'], $_POST['year2']) ?> </form> As far as adding to the database, depends what database your using, the structure, etc, etc, etc.
  23. Unfortunately I haven't got it installed right now, but you might want to look at getting ietester, it allows you to check websites in IE8, IE7 IE 6 and IE5.5 on Windows 7, Vista and XP. Very usefull for developers.
  24. Last time I checked 24:15 wasn't a valid military time where I'm from.... Assuming that was a little mistake, how about this? <?php if(strtotime($str)) { echo "Pass"; } else { echo "Fail"; } ?>
  25. Is there a reason you can't use... <?php if(isset($_GET['ptid']) && $_GET['ptid'] == 5) { ?>
×
×
  • 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.