-
Posts
16,734 -
Joined
-
Last visited
-
Days Won
9
Everything posted by PFMaBiSmAd
-
URLs in emails must be fully qualified absolute address.
-
Unlikely, as it only takes a few lines of php code to automate the solving of your text based math problem, i.e. scrape the string out of the form page, solve the math using an eval() statement, submit to your form processing page. However, if you output the whole math question ON an image, and use randomly worded questions with random values in them, it will become much more difficult for an automated script to solve this as it must first do OCR to even read the math question. Typical image captchas have 4-8 characters or a word or two to read and input. Doing the OCR to read a smaller number of characters is going to be more accurate than reading a larger number of characters, symbols, and numbers. If you output the whole math question with several words, numbers, and number names in it, just getting the OCR to accurately return all the words to even parse by a script will thwart all but a dedicated spammer. Also, you need to clear the $_SESSION variable after you successfully test it in the form processing code so that someone cannot enter the correct answer once and repeatedly submit to the form processing code and you need to check if the $_SESSION variable is NOT empty, because an empty session variable will be equal to an empty post variable every time.
-
When someone finalizes an order, you would insert a row into an `order` table. That table would have the order_id as an auto-increment column. It would also have columns for the user_id, order date, order status, shipping information... You would get the auto-increment value from the above table using a function like mysql_insert_id and use that value when you insert the details of the order into your order_id, product_id, order_quantity table.
-
See the solution in your previous thread - http://www.phpfreaks.com/forums/index.php?topic=332258.0 , where you had an almost identical query error message.
-
You have set the method to the script_name in the following - method="<?php echo $_SERVER['SCRIPT_NAME']; ?>" That should be - action="<?php echo $_SERVER['SCRIPT_NAME']; ?>"
-
For every place-holder/format-specifier that you have in the first parameter of the sprintf statement, you must supply a value. You need to match up each piece of data you are supplying with the where it is being used in the query and determine which piece of data is missing and add it to the list of arguments.
-
You sure do like to repeat code. At the point where you have finished validating all the data, you would either insert the successful data (what your code is doing now before your latest post above) or you would log the reason(s) for the unsuccessful attempt - if (count($aError) == 0) { // --process form here-- ...... } else { // log the reason(s) for the unsuccessful attempt here... } Since this is a registration form/scirpt, you wouldn't log the unsuccessful information into the same table (which is what the query you just posted above is doing) where you are inserting your successful form submissions.
-
How can I display this from an included file ??
PFMaBiSmAd replied to spacepoet's topic in PHP Coding Help
You need to restart your web server to get any changes made to the master php.ini to take effect and you need to confirm that the values actually changed using phpinfo() statement (in case the php.ini that you are changing is not the one that php is using.) -
The code you have, which you either got directly or indirectly from w3schools, is just about worthless. When they added the combined [type]/ check, they added it before the error check logic and now it reports an Invalid file when upload errors occur and you never see any upload error messages. A) You must always check that the upload worked before you attempt to use any of the uploaded file information. The [type] is empty and won't match anything when there is an upload error. B) You should NOT lump different validation checks into one conditional statement. This hides information about why the test failed. That code will report Invalid file when either the type or size test fails. Wouldn't it be better to output a separate message telling the visitor that the type was not supported or that the file was too large? C) As long as it is not security related, you should tell the visitor exactly why a validation test failed, including outputting the value that failed the validation test as part of the error message so that the visitor can see what the code was using that failed. If you output the actual upload [type] or information that failed a test, it will give the visitor more information about what were doing wrong (perhaps they accidentally selected a non-image file to upload) and it will give you debugging information when you are testing your code (you would be able to see the actual [type] that the browser sends.)
-
GROUP BY DATE(FROM_UNIXTIME(p_time_posted))
-
How can I display this from an included file ??
PFMaBiSmAd replied to spacepoet's topic in PHP Coding Help
Without the code that would be needed to reproduce the current problem, we cannot help much. It could be your include statement, how you are setting the variables, the php tags being used, the code in the included file being inside of a function... However, I can just about guarantee that setting the error_reporting/display_errors settings as suggested would help pin down what is causing the problem. -
You will need to use the mysql FROM_UNIXTIME() function in your query to get the values into a yyyy-mm-dd value. From there, you can GROUP BY the part(s) of the date you want and use COUNT() to get a count of the number of records in each group. Unix timestamps are the worst way to store date/time information that you need to manipulate based on calendar divisions.
-
Unix timestamp (integer value) or mysql timestamp (yyyy-mm-dd value) ?
-
<?php $path = "stories"; $story = isset($_GET['story']) ? basename($_GET['story']) : ''; // condition input $files = glob("$path/*.html"); // list of all files sort($files); if(empty($story)){ // get the lastest one $newest = end($files); echo "Story from: $newest<br />\n"; include($newest); } else { // get the story based on $story // $story is the basename of value supplied on the end of the url $file = "$path/$story"; if(file_exists($file)){ // requested file exists in the correct folder echo "Story from: $file<br />\n"; include($file); } else { // file does not exist echo "The requested story for: $story, does not exist!"; } } // archive links $last_yr = ''; // remember the last value $last_mo = ''; // remember the last value if(is_array($files) && !empty($files)){ foreach($files as $file){ // path/yyyymmdd.html $name = basename($file,'.html'); preg_match("/(\d{4})(\d{2})(\d{2})/", $name, $matches); // $matches[1], [2], [3] = year, month, day if($last_yr != $matches[1]){ // new year heading echo $matches[1] . "<br />\n"; $last_yr = $matches[1]; // save the new value } if($last_mo != $matches[2]){ // new month heading $mn = date('F',mktime(0,0,0,$matches[2],1,1970)); echo $mn . "<br />\n"; $last_mo = $matches[2]; // save the new value } // output the data echo "<a href='?story=$name.html'>$matches[3]</a><br />\n"; } } else { echo "There are no stories available!"; } ?>
-
if($post >= 5 && $post <= 10)) //five through ten {then do this}
-
I would use a database to store the content of each story and just use a $_GET parameter on the end of the URL to determine which store to retrieve the content for and output it on one single page (i.e. a simple content management system.) This will eliminate the need to make a copy of each page (or of your master page) and edit it. You would make the links to the archive by retrieving a list of all the available stories (either from a database or by using the glob() function on your files.) You would then loop through the list of the available stories and get the year, month, and day information from each one. When the year value changes, you would output a new year heading. When the month value changes, you would output a new month heading. You would then output each day as a <a href=""></a> link. The links would contain an id as a get parameter on the end of the url that indicates which story to retrieve (database) or include (file) into the page.
-
A error from the php language engine and two different people, one of which posted fixed code, have pointed to your code that is missing the $ on some variables. I suggest you look at your code again.
-
You shouldn't use elseif logic when validating different form fields because only the first test to fail will be reported. You will piss off your visitors if they have to repeatedly submit the form, once for each validation problem. You want to validate and report all the independent problems at once. The only time you would use elseif logic when validating form data is when you are performing related tests on one value and you want the validation to stop on the first error, such as first checking if a value is empty, followed by checking if the value is too short. If it is empty, you don't want to display that it is was also too short.
-
Php variable names start with $
-
Are you sure your first example isn't BLUE? // set $int equal to your integer values - $hex = sprintf("%06s",strtoupper(dechex($int))); echo $hex;
-
How can I display this from an included file ??
PFMaBiSmAd replied to spacepoet's topic in PHP Coding Help
You should be developing and debugging your code on a system with error_reporting set to E_ALL and display_errors set to ON in you master php.ini so that all the php detected errors will be reported and displayed. You will save a TON of time. In the first code in this thread and probably the last code as well, you would have gotten an undefined variable message since the $mySideBarPageData doesn't exist inside the function, as has been stated in the replies in this thread. -
I have looked at your logic more, and it is not even doing what you expect. For each validation test, some with conditions that are backwards from what you probably intended, you are executing the INSERT query. In the pseudo code I posted, you would only execute the query where the // use form data comment is.
-
Before you worry about redisplaying the entered values in the form, you need to fix the logic on that page. You are repeating your form code 6 times. You should only have the form code present ONCE, near the end, after you have validated the form data. You should only display the form if the page was browsed to (not a form submission) or if there are any validation errors. Here is the general logic needed - // Form/form processing pseudo code // form processing code if(form_submitted){ condition and validate form data if(no form_errors){ // use form data } } // form code if(form_not_submitted OR form_errors){ if(form_errors){ display form errors } display form with existing field values (if present) }
-
You need to use an array for your form field(s) - http://us.php.net/manual/en/faq.html.php#faq.html.arrays Once you do this, you can use php's array functions, such as foreach, to iterate over the data. Any time you find yourself trying to make a series of numbered variables for a set of data, you should be using an array (arrays are for sets of related data.)