First off, hello DigitalPoint Community! Now, down to business. Ok, so I managed to create my own site now. The problem is, for example, if a customer buys something, he receives a tracking number. Then he can insert the tracking number to see the status of his transaction. What I want to do is the following. I want when he press track, even if he didn't enter nothing, or a wrong track number, to avoid the display of the 404 page not found. I would like to show, when generally wrong track number, a similar page like... error, the tracking number is wrong or something like this. Do you think guys you can help? Because I create the tracking numbers with dreamweaver, and they are .html Do I need a php script or something like this? Please shed some light please, I m totally lost and I don't like this with a blank page What I have is this <script language="JavaScript">function PasswordLogin() { document.location.href = document.formlogin.trackingnr.value + ".html"; return false; } function CheckEnter(event) { var NS4 = (document.layers) ? true : false; var code = 0; if (NS4) code = event.which; else code = event.keyCode; if (code==13) { PasswordLogin(); event.returnValue = false; } }</script><br> ////then here some htlm and then///// <input name="trackingnr" id="trackingnr" onkeypress="CheckEnter(event)" size="29" type="text"> <input name="button" onclick="PasswordLogin()" value="Lookup" type="button"> Code (markup): So I would like, something like, if false, to return a page with a customize error or something.... It's not difficult, but I couldn't find what I want, because simply I don't know what is called.... So I am uploading the traking number myself, like FFFGS23.html and if the customer types it wrong, or simply press submit without filling anything in the space, it comes the 404 Error. AND I DON"T want that to happen. I detalied it, hope I can get some help tho and I don't know what suits me better javascript or php here...
Problem solved here. http://www.programmingtalk.com/showthread.php?p=129664 EDIT: Always PHP, you could do something like: <?php $filename = strtoupper(basename($_POST['trackingnr'])) . '.html'; if (file_exists($filename)) { header('Location: ' . $filename); exit(); } else { echo 'Invalid tracking number.'; } ?> PHP:
Thanks again Nico. I'm working on it, hope it will solve. Btw yo soy de Alicante! Just trying to understand why it gives me the error when the GOOD tracking number is inserted, and not when a bad one.
Problem solved, Thread closed. For me this code is priceless Nico! Thank you again! Profoundly indebt!