Jump to content

cyberRobot

Moderators
  • Posts

    3,145
  • Joined

  • Last visited

  • Days Won

    37

Everything posted by cyberRobot

  1. Have you tried something like the Autofill Forms plug-in for Firefox? https://addons.mozilla.org/en-US/firefox/addon/autofill-forms/
  2. Although it requires a little more work to tamper with $_POST variables, it can be done. I'm not as familiar with $_SESSION variables. But in the end, you need to pass the data using GET or POST before being able to set a SESSION variable. As for the security issue, don't send price through the form. Only send what needs to be sent. If this was my form, I would [*]Store all the event information in a database [*]Use the database to populate the form options for the event [*]Have the user complete the form...which would only pass the event ID and number of registrants [*]Verify that event ID and number of registrants are numbers [*]Make sure the event ID exists in the database [*]Have them sign in / create an account [*]Pull all the necessary event information from the database using the passed event ID [*]Calculate the registration total [*]Collect the billing information [*]Ask user to verify their order and give them an option to edit the order [*]Display the receipt If the database contains dozens (or more) of things they can register for, I would lean towards using a link for each of the events which would only pass the event ID. Then the next step would ask them for the number of attendees and continue through the steps outlined above.
  3. Yep, if you want to collect data, you'll need an HTML form. Does the 1st step need to be set up like above? I'm not a fan of using multiple forms on a single page. Could you, for example, change the setup to ========================= Which event would you like to attend? << radio button >> Flower Show (Mankato, MN; Sept 24, 2011; $20/per person) << radio button >> Flower Show (Willmar, MN; Oct 1, 2011; $20/per person) << radio button >> Banjo Jamboree (Brainerd, MN; Oct 8, 2011; $50/per person) Number of attendees? << text field >> Total: << calculated total goes here - if needed >> << submit button >> ========================= Or if you prefer to HTML links, you could just ask for the number of attendees in the next step. But then it would be "4 easy steps".
  4. It seems like you have a solution that works, so I'm not exactly sure what you're asking. If you're looking for more efficient code, you could just use "else". if ($Username == $Likeobj->username){ $LikeMe = "<td class='UnderTable' align='center' width='10%'><a href='?unlike=".$update[id]."' title='Unlike This News Post?'>Unlike</a></td>"; }else{ $LikeMe = "<td class='UnderTable' align='center' width='10%'><a href='?like=".$update[id]."' title='Like This News Post?'>Like</a></td>"; } Or you could go even further with the Ternary Operator: $LikeMe = "<td class='UnderTable' align='center' width='10%'>"; $LikeMe .= ($Username == $Likeobj->username) ? "<a href='?unlike=".$update[id]."' title='Unlike This News Post?'>Unlike</a>" : "<a href='?like=".$update[id]."' title='Like This News Post?'>Like</a>"; $LikeMe .= "</td>"; Note that I separated out the table column code since it's the same for both cases.
  5. Either option (multiple forms / anchor tags) should do the trick. With that said, I would go the anchor tag route since it would require less code. If you prefer the look of the submit buttons, you could always create an image for the anchor tags.
  6. Maybe I'm missing something, but is there a reason you're using foreach loops for some of the $_POST variables? For example, this <?php //... foreach ($_POST['visit'] as $value) { $Church = trim(stripslashes($value)); } //... ?> should be the same as: <?php //... $Church = trim(stripslashes($_POST['visit'])); //... ?>
  7. How do you expect the page to work? If you want visitors to select multiple events, you could use a single form with checkboxes...one for each event. If you only want visitors to select one at a time, you could create several forms with one submit button. Or maybe the multiple submit buttons in one form that others are suggesting. You could even use regular links. <div><a href="cart.php?select=CarShow">Add to Cart - Car Show</a></div> <div><a href="cart.php?select=CraftShow">Add to Cart - Craft Show</a></div>
  8. Sorry, just noticed that you're already using array_rand(). You could simplify the code by doing something like: <?php //... $random1 = array_rand($l_numbers, 5); sort($random1); echo implode(', ', $random1); //... ?>
  9. Have you looked into array_rand(): http://php.net/manual/en/function.array-rand.php For the sorting part, you could look into sort(): http://us3.php.net/manual/en/function.sort.php
  10. Whenever possible, it's more secure to make sure the value is what you expect. Numbers, for example, could be validated with the ctype_digit() function: http://php.net/manual/en/function.ctype-digit.php If you expect a number and you get something else, it's better to let the user know about the error instead of trying to insert it into the database. Also, you may want to re-read mjdamato response; especially the part about mysql_real_escape_string() only being effective with "text" inputs.
  11. No problem, I totally understand the frustration of only receiving negative comments. Glad to hear that the issue was resolved.
  12. The issue seems to be caused by the double-query / double-loop thing you have going on. First you have the $sql variable which is being processed twice: <?php $sql = "SELECT uid, id, imageurl FROM dave_usergallery WHERE sex='M' ORDER BY id DESC LIMIT $limit_start, $items_per_page"; //... $result = mysql_query($sql) or die("Error: " . mysql_error()); //... $items = mysql_query($sql); ?> Then you have two while loops, one to process $items and the other to process $result. The code should work fine if you just remove the second while loop. Try changing this: <?php echo "</small><br/><a href=\"$item[2]\" alt=\"$userinfo[0]\"/>Download<br/>"; while($row = mysql_fetch_array($result)){ echo "<br/><a href=\"getpics.php?file=$row[id]&sid=$sid\">Download test</a>"; echo "<br/>"; } echo "</small><br/><br/>"; ?> To this (note that I changed $row to $item): <?php echo "</small><br/><a href=\"$item[2]\" alt=\"$userinfo[0]\"/>Download<br/>"; echo "<br/><a href=\"getpics.php?file=$item[id]&sid=$sid\">Download test</a>"; echo "<br/>"; echo "</small><br/><br/>"; ?>
  13. For what it's worth, if you want to use the leading slash, you just need to add the document root info: <?php require_once($_SERVER['DOCUMENT_ROOT'] . "/includes/header.php"); ?> Note that using a root-relative link is beneficial if you copy & paste template code from one page to another...and some of the pages exist deeper in the directory structure.
  14. It's a little difficult to tell what's going wrong without seeing more code. So is there a reason why you're setting the session variable in two different spots?
  15. Did you try echoing $_SESSION['ref'] throughout the program to see where it's getting lost? For example, I would attempt to echo it before, inside, and after the "require_once("http://mysite.com/includes/header.php");" code. Note that you'll want to echo something else with the variable. That way if the variable is empty, it will be easier to tell. For example: echo "({$_SESSION['ref']})"; Or you could use var_dump() http://php.net/manual/en/function.var-dump.php
  16. When using a .php extention for the include, variable scope seems to change. Maybe sessions are affected also. Have you tried adding session_start() to header.php? You could also look into changing the include to something like header.html
  17. No problem, hope everything works out.
  18. Example #4 on the PHP Manual page for mail() should guide you in the right direction: http://php.net/manual/en/function.mail.php
  19. You should be able to modify the code I provided earlier to fit your needs. I'm not sure which column is being used to search for matches, I also don't know what the form code looks like. Basically, all you need to do is something like: <?php $sql_combine = ''; //variable to add " OR " between the various checkbox queries; note that it's set to nothing since we don't want the an or before the first test $sql = "SELECT * FROM users WHERE "; if($_POST['checkbox1']) { $sql.=$sql_combine."status='".$_POST['checkbox1']."'"; $sql_combine=' OR '; } if($_POST['checkbox2']) { $sql.=$sql_combine."status='".$_POST['checkbox2']."'"; $sql_combine=' OR '; } mysql_query($sql); ?> You'll need to replace "status" with the column that corresponds with the checkboxes and change the $_POST['checkbox1'] variable to whatever you named the checkboxes. Also, if the form uses the GET method, you'll need to use the $_GET array.
  20. Could you provide a sample of what your database look like? If you have a database where one column contains one of the checkbox values, the query would use "OR". <?php $sql = "SELECT * FROM your_table_name WHERE column_to_search='" . $_POST['checkbox1'] . "' or column_to_search='" . $_POST['checkbox2'] . "'"; mysql_query($sql); ?> Note that you could use a look to generate the WHERE clause to test for the various checkbox values. Also you'll want to validate the checkbox values before using them against the database. Otherwise, you'll want to use the mysql_real_escape_string() function: http://php.net/manual/en/function.mysql-real-escape-string.php
  21. How long did you wait for the e-mail? Sometimes it may not be instant. Maybe the mail server is backed-up? Are the messages being caught by your spam filter?
  22. There are many ways, but my preferred method is: $firstTime = true; foreach ($array as $tag) { if($firstTime) { echo "$tag"; firstTime = false; } else { echo ",$tag"; } }
  23. Well, I would hate to see you leave...but they'll probably be better at answering your questions. Good Luck!
  24. Have you tried Smarty's forum? http://www.smarty.net/forums/
  25. Does this help: http://www.smarty.net/docs/en/language.modifier.spacify.tpl If not, I'll butt out since I've never used Smarty before.
×
×
  • 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.