Jump to content

cyberRobot

Moderators
  • Posts

    3,145
  • Joined

  • Last visited

  • Days Won

    37

Everything posted by cyberRobot

  1. In case you don't want to use regular expressions, you try something like the following: <?php $testVal = $_GET['testVal']; //<-- add value to test here; I just used a GET variable for easy testing $letters = array(); $numbers = array(); for($i=0; $i<strlen($testVal); $i++) { if(ctype_digit((string)$testVal[$i])) { $numbers[] = $testVal[$i]; } else { $letters[] = $testVal[$i]; } } print '<div>Letters: ' . implode('', $letters) . '</div>'; print '<div>Numbers: ' . implode('', $numbers) . '</div>'; ?>
  2. So where are you stuck? It may be helpful to describe what you mean by doesn't work. What does the code for mailer.php look like? Also, please surround code with the tags. They make the post (and code) easier to read.
  3. As Jessica mentioned, you'll need to wrap the entire table row with the if statement instead of the individual column values. You could, for example, do something like this: <?php while($OnlineName = $result->fetch_object()) { if($OnlineName->online == "1") { echo '<tr>'; echo "<td>$OnlineName->player</td>"; echo "<td>$OnlineName->permission_group</td>"; echo "<td>$OnlineName->current_world</td>"; echo '<td>' . date("F j, Y, g:i a", $OnlineName->logon_time) . '</td>'; echo '</tr>'; } } ?>
  4. Do you have any code where you attempted to put data in a "text field"? If you're looking to populate a form field, maybe this will help: http://forums.phpfre...m/#entry1393942 Side note: you're probably already aware of this, but the mysql_* functions have been depreciated. It might be time to look into an alternative. More information can be found here: http://php.net/manua...ysql-result.php
  5. Technically, the built in PHP functions along with the rest of the language is someone else's code...I know what you mean though.
  6. One problem with the back-end code is it's only processing one set of fields. You'll need to add some type of loop to go through the form input. It isn't too much different than what you have for the front end.
  7. The ID could be added after the field name: echo "<input type=\"text\" name=\"title$nameid\" value=\"$title\">"; Or you could use an array: echo "<input type=\"text\" name=\"title[$nameid]\" value=\"$title\">"; More information about arrays in HTML forms can be found here: http://www.thefuture...tml-form-inputs
  8. Is there something specific about the echos that bothers you? If you don't like having to escape the double quotes, you could change some of the lines to single quotes. Just be aware that variables (and special characters like "\n") won't work inside of single-quoted strings. <?php echo '<tr>'; echo '<td style="padding-left: 5px; padding-right: 5px" class="mainlevel"><b>'; echo '<label id="searchlink' . $id . '" rel="subcontent' . $id . '">' . $name . '</label>'; echo '</td>'; ?> You could also consider jumping in and out of PHP. Of course, this can get a little messy too. <tr> <td style="padding-left: 5px; padding-right: 5px" class="mainlevel"><b> <label id="searchlink<?php echo $id; ?>" rel="subcontent<?php echo $id; ?>"><?php echo $name; ?></label> </td>
  9. The form inputs need to have their own individual names. Otherwise, PHP isn't going to know the difference from one field to another. Maybe the following link will help: http://www.tizag.com/phpT/forms.php
  10. Have you tried the examples in the manual (http://php.net/manua...res.foreach.php)? Understanding the code may help you adapt the for loop.
  11. What does your code look like so far?
  12. In the first code block, have you tried getting rid of the duplicate call to mysqli_fetch_assoc()? $blogPosts= mysqli_fetch_assoc ($r); //<-- REMOVE THIS ONE while ($blogPosts= mysqli_fetch_assoc ($r)) { //foreach ($blogPosts as $key => $value){
  13. Here's a quick tutorial on building forms and processing them with PHP: http://www.tizag.com/phpT/forms.php Note that there are many other tutorials available through Google: https://www.google.c...rocessed by php
  14. Have you considered merging the hidden field into the link? <div class="followbuttonbox"> <a href="<?php echo $_SERVER['PHP_SELF']; ?>?ID=<?php echo $profileid; ?>&followbutton=true"><img src="/images/follow.png" id="followbutton" /></a> </div> You would need to change and $_POST references to $_GET.
  15. Here's a solution using Javascript: http://www.javascrip...pt/cut174.shtml There are many other options available through Google: https://www.google.c...ed on drop down
  16. When passing through the URL, those are called GET variables. Have you looked into retrieving the information with $_GET? http://php.net/manual/en/reserved.variables.get.php
  17. In case it was missed, you could use the first part of Christian's if statement. <?php if(!empty ($address_postcode) && !preg_match("/^[a-z]{1,2}[0-9]{1,2} [0-9]{1,2}[a-z]{1,2}$/i", $address_postcode)) { print "Postcode needs to be in Se24 8IO Format "; } ?>
  18. Did you see the link I posted in Reply 6? It may help you with the join.
  19. You should be able to grab the products table and use a Left Join (http://www.tizag.com...sqlleftjoin.php) to get the user's order information based on the product ID. You'll need to grab something from the user order database, like the row ID. Then as you're looping through the products, you can check if the row ID field contains a value. If it does, display the warning. Otherwise, display the button. As a side note, I would recommend against passing product information (such as price) through the form. <form action="addtocart.php" method="post"><input name="product" type="hidden" value="<?php echo $title; ?>" /><input name="price" type="hidden" value="<?php echo $price; ?>" /> It's fairly easy for someone to re-create the form, modify the price to 0, and submit the results to your addtocart.php script. Instead, you can pass just the product ID. The addtocart.php script would then use the ID to get the necessary product information.
  20. It might also be helpful to show some code. One thing to look for is if the special character is enclosed in single quotes. For example, the following doesn't work: <?php print 'here\n'; ?> It needs to be changed to double quotes. <?php print "here\n"; ?>
  21. You'll need to have an if statement that detects the form submission. I usually do something like the following: <?php if(isset($_POST['processForm'])) { //process form here print 'here'; } ?> <!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>Untitled Document</title> </head> <body> <form method="post" action="pagename.php"> <input type="hidden" name="processForm" value="1" /> <input type="submit" value="submit" /> </form> </body> </html>
  22. It would help to see the new code. Also, it helps to describe what you mean by it doesn't work. Are you getting errors? If so, what are they?
  23. You may also want to look into SQL injections (http://www.tizag.com...l-injection.php) XSS attacks on PHP_SELF (http://seancoates.com/blogs/xss-woes)
  24. Have you considered the Honeypot technique? This can help prevent form spam without getting in the way of most users. More information can be found here: http://haacked.com/a...ot-captcha.aspx
  25. Other than needing to be six characters, are there any rules for the password? For example, does it need to include at least one special character and/or number? If so, checks can be added to make sure the password meets whatever criteria is in place. When comparing the username against other usernames in the database, how does it handle case? Unless the username field in the database is set to be case sensitive, "MyUsername" and "myusername" will be considered the same. PHP, on the other hand, will treat them as different usernames. To prevent a potential conflict, the PHP test could be modified. <?php if(strtolower($username) == strtolower($use["user_username"])){ ?> As a side note, the <label> tags are incomplete. An "id" attribute needs to be added to the <input> tags and a matching value needs to be added to the "for" attribute in the <label> tags. For more information, see: http://www.cyberscor...-the-label-tag/
×
×
  • 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.