Jump to content

Psycho

Moderators
  • Posts

    12,157
  • Joined

  • Last visited

  • Days Won

    129

Everything posted by Psycho

  1. Well you error is on this line, just add a comma as indicated array_push($insertvalue, ", email='" . $_POST['email'] . "'"); However, there is a LOT more wrong with that code. For example, you are using the POSTed values directly within the SQL statements. That's just an open invitation for SQL injection. Hope you back up that database very frequently. Also, the error you are getting is because the query is failing. Basically the writer of that code "assumed" that the code would only fail if the username was not new since the value is apparently set as unique in the database. That is very poor methodology in my opinion. You should first check if the name is unique to determine if that is a problem. If not, then attempt the insert. If the insert fails then you need to find out why.
  2. Unfortunately there is not going to be a 100% effective, programatical solution to your problem. You could just as easily have a track with a hyphen in it. I have run into this problem as well with regard to parsing artist/track names. My suggestion is to create a "white" list of artist exceptions which include the hyphen. When processing the data see if the artist matches anything in the white list, if so, parse using the first hyphen after the name in the white list. If not, then split using the hyphen. If there are only two pieces of data after the split, you're good to go. If there are more than two elements after the split than flag that record as an error (or just assume everything after the first hyphen is the title). Really just depends on how accurate the data needs to be and the time you can invest to correct it.
  3. Why not build a solution that pulls the tracking info directly from the courier and display on your site. All the major couriers off this functionality. Here's a link to UPS's solution: http://www.ups.com/content/us/en/tracking/tools/index.html
  4. Sorry, the 1==1 and 2==2 were my playing with the code to validate that the "window.opera" and the "window.print" were not the cause of the problem (for example, maybe the window.opera was expecting some code to follow). So, I decided to change the 'tests' to something I absolutely knew should work to rule that out. Just change those tests back to what you originally had.
  5. OK< found solution to the other problem with a Google search. I'm not entirely familiar with this or why so do any additional searching as needed. But, you need to wrap your javascript code is CDATA tags as follows: <script type="text/javascript"> //<![CDATA[ function bookmarksite(title,url) { if (window.sidebar) { // firefox window.sidebar.addPanel(title, url, ""); } else if (1==1 && 2==2) { // opera var elem = document.createElement('a'); elem.setAttribute('href',url); elem.setAttribute('title',title); elem.setAttribute('rel','sidebar'); elem.click(); } else if (document.all) { // ie window.external.AddFavorite(url, title); } } //]]> </script>
  6. Only if you are not actually POSTing those values. Otherwise I don't know how the data will come across to the processing page.
  7. The only place you are using the form name is within the triggers. And, you are using it to pass an object. Just give those objects an ID and pass using getElementById(). (NOTE: not sure if it is a typo or not, but the code you posted is referencing a field called 'prod_serv', but you have a field called 'prod'.) <form method="post" name="myForm" action="process.php"> <textarea name="prod" id="prod" cols="72" rows="3" onkeydown="textCounter(document.getElementById('prod'), document.getElementById('remLen1'), 255)" onkeyup="textCounter(document.getElementById('prod'), document.getElementById('remLen1'), 255)"></textarea> <br /> <input readonly="readonly" type="text" name="remLen1" id="remLen1" size="3" maxlength="3" value="255" /> characters left </form> For the second problem, I am assumign the bold tags () were only added for the forum post to try and bold it for emphasis (but does not work within code tags). I would thinkn that would work. Try doing this: else if((window.opera) && (window.print)){ // opera
  8. Put all the help divs within a container div and use the function below <html> <head> <script type="text/javascript"> var divList = new Array(); function helpcontents(divid) { helpDivs = document.getElementById('helpDivList'); // alert(helpDivs.childNodes.length); for (var i=0; i<helpDivs.childNodes.length; i++) { if(helpDivs.childNodes[i].id) { helpDivs.childNodes[i].style.display = (helpDivs.childNodes[i].id==divid) ? 'block' : 'none'; } } } </script> </head> <body> <a href="javascript:;" onmousedown="helpcontents('G1')">General site introduction</a> <a href="javascript:;" onmousedown="helpcontents('A1')">Admin introduction</a> <div id="helpDivList"> <div id="G1" style="display: block;"> <span class="help_title_text">General</span> <p> Welcome to V.E.I.N. or Video Entertainment Interactive Network! </div> <div id="A1" style="display: none;"> <span class="help_title_text">Administrative</span> <p> As an administrator of V.E.I.N. you will be expected to provide a good example of the sites standards. </div> </div> </body> </html>
  9. It was a typo on my part, but which I would expect you to catch. As stated in my signature "I do not always test the code I provide..." There are two problems: one, the form is using the field name "selections" and part of the code in the processing script is using "options". Also, the $optionsList array used inthe processign script is using different values than used on the form. Replace the corresponding sectino in the PHP code with this: //These must match EXACTLY the values of the checkbox values $optionsList = array('item 1','item 2','item 3'); foreach($optionsList as $option) { $forminfo .= "$option: " . ((in_array($option, $_POST['selections']))?'Yes':'No') . "\n"; }
  10. For the checkboxes, I would do this. In the HTML form <input type="checkbox" name="selections[]" value="item 1" /> Item 1<br /> <input type="checkbox" name="selections[]" value="item 2" /> Item 2<br /> <input type="checkbox" name="selections[]" value="item 3" /> Item 3<br /> Then within the Javascript tags add this function function optionSelected(checkGroup) { for(var i=0; i<checkGroup.length; i++) { if (checkGroup[i].checked) { return true; } } return false; } and within the form validation add this after the "else if" line if(f!optionSelected(formObj['selections[]'])) { errors[errors.length] = 'Must select at least one option.'; } Now, in the PHP validation code add this in the PHP validation section, also after the "else if" line if(!isset($_POST['selections'])) { $errors[] = "Must select at least one option."; } Finally, within the code the builds the email add this where you want the output to be, if you only need the selected options to be displayed you could use this $forminfo .= "Selected options:\n"; foreach($_POST['selections'] as $option) { $forminfo .= " - " . $selection . "\n"; } Or if you need all the options printed with a yes/no, then you would have to create an array of all the options in PHP and do this: $optionsList = array('Option 1','Option 2','Option 3'); foreach($optionsList as $option) { $forminfo .= "$option: " . ((in_array($option, $_POST['options']))?'Yes':'No') . "\n"; } For the problem with the thank you page, I think you would need to either build a flat HTML page that includes that left bar or you would need to figure out how to include the welcome page into one of the Zen pages.
  11. Yes, that is one of the scenarios I described above. But, you need to make a decision.. When the user selects the Export button do you want to create a physical file on the server before serving it to the user OR do you want to create a "virtual" file each time the user creates a report and send that to the user. If you do not need to keep copies of the reports (on the server) for historical purposes then you should NOT create physical files on the server. The small snippet of code I posted above will do exactly what you are asking. Assume that code is the page that is called when the user selects the Export button. Just replace this line $content = "Report info"; with all of the code you now use to generate the report file (just assign the report content to the variable). If you still don't understand, post the code you have for the page that is called when the Export button is called and I'll give more specific details.
  12. OK, glad you kept working on it. I saw you responses and was going to rewite the code I laready provided when I actually "read" your third post. Glad it's all working. Please mark the thread as solved!
  13. In any case, this should be handled server-side, not in Javascript. Wrong forum.
  14. OK, your last response doesn't fit with your first post. What exactly are you wanting to do. You state in the last post that you are creating a link for the user to get the report. Is the problem that the reprot opens in the browser instead of saving to the user's machine? In that case you need to add the required headers to "force download" so the file will not automatically open in the user's browser. However, if you want the PHP script to automatically write the file to the user's PC, then as I said before that is not possible without the server being able to access the user's PC through a network share and the user specifying the path to that share from the server. If you are only wanting to provide the txt for the user to download to their machine, then you don't even need to write the file to the server (if you don't need to save it). Just "build" the file in your PHP script and serve it to the user to download. Here's a short example: //Create code to generate the report content as a variable $content = "Report info"; header("Content-Type: text/html"); header("Content-Disposition: attachment; filename='name.txt'"); echo $content; If you created that as a page and pointed your browser to it you would be prompted to download the file 'name.txt' which willhave the text 'Report info'.
  15. Are you wanting to write the file to the server or to the user's computer. If you want the user to save to the server you would want to build a PHP based file browser (I have a script on my PC at home, but you should be able to find something on the web). If you want to save the file to the user's PC it will not be straitforward. The user can't select "C:\directory\" to save on their PC because the server is the one doing the writing. The user would have to indicate the path to the directory on their machine from the server assuming the server even has access to the user's PC. Something like "\\users_pc\sharename\directory\". I suspect you *may* be able use a PHP file browser that can navigate network shares, but I've never needed to do that.
  16. Although I've never worked with the Zen Cart framework, I have to believe there is a way to create dynamic pages with PHP as opposed to just flat HTML pages. But, to change it as you request is simple, just go with the format you had previously where you have a flat HTML file and a separate PHP page for processing. On the email_form.php code, strip out all the PHP code. You will then have to hard-code the select list and set the action of the form to the PHP processing page. The index.php page would be your processing page. Just remove the last line and instead include code to present an error page to the user (using the $error_msg string) and a link to return back to the form.
  17. Well, personally, i would just use the command that is already built into the application: mysql_insert_id() http://us.php.net/mysql_insert_id mysql_insert_id mysql_insert_id — Get the ID generated from the previous INSERT operation OR, if you need to use it in a query: $query = "UPDATE table SET foo = 'bar' WHERE id = LAST_INSERT_ID()";
  18. This will do that. Note that I changed the function to accept a parameter (the field ID) and that I added it to the onclick trigger. <script type="text/javascript"><!-- function Bolden(fieldID) { var fieldObj = document.getElementById(fieldID); fieldObj.value = '<b>'+fieldObj.value+'</b>'; return true; } //--></script> </head> <body> <a style='cursor: pointer;' onClick="Bolden('chatmsg')"><b>Bold</b></a> <input id="chatmsg" type="text" size="60" maxlength="80" onkeyup="keyup(event.keyCode);">
  19. There are only a few major browsers. The only way to really know if the script will work in any browser is to test it. However, that script is fairly basic and I *doubt* there would be any problems. However, I hope you realize that you should not rely upon the JavaScript to prevent too much data from being entered. It is a nice real-time indicator to the user, but can not be relied upon because a user can turn-off javascript processign in their browser. Also, that script is not complete because it allows you to paste as much text into the field as you want. There should also be an on-blur event to process data input using the mouse.
  20. Works fine for me in both IE and FF. However, they both display very differently in thos two browsers - you'll need to work on the CSS to get them to display consistently. My guess is that you are not passing an ID to the function for an element on the page or one that does not support innerHTML. Here is what I used to test. <html> <head> <script type="text/javascript"> function setStatus(id,first){ var status = document.getElementById(id); var stat = ''; stat += '<div style="vertical-align:top;max-width:100px;border:solid 1px #AAA;border-right:0;padding:5px;font-size:18px;display:table-cell;font-weight:bolder;">'+first+'</div>'; stat += '<div style="vertical-align:top;padding:5px;border:solid 1px #AAA;border-left:0;display:table-cell;width:200px;">'; stat += '<input type="text" id="setStatus" rows="1" style="font-family:verdana, arial, times;border:0;outline:none;font-size:18px;color:#AAA;" class="bold" />'; stat += '</div>'; status.innerHTML = stat; document.getElementById('setStatus').focus(); } </script> </head> <body> <h3>Hard coded HTML:</h3><br> <div style="vertical-align:top;max-width:100px;border:solid 1px #AAA;border-right:0;padding:5px;font-size:18px;display:table-cell;font-weight:bolder;">Ryan</div> <div style="vertical-align:top;padding:5px;border:solid 1px #AAA;border-left:0;display:table-cell;width:200px;"> <input type="text" id="setStatus" rows="1" style="font-family:verdana, arial, times;border:0;outline:none;font-size:18px;color:#AAA;" class="bold" /> </div> <br><br> <h3>Dynamically generated from JS (span with the id of 'test'):</h3><br> <span id="test"></span> <br> <button onclick="setStatus('test', 'Ryan')">Run setStatus('test', 'Ryan')</button> </body> </html>
  21. Did you even try the code I provided? There were a lot of issues in your code and it was easier to fix them than to explain it all. I really think you will be happier with the process flow I provided. Here is a short description of it: 1. When page loads, check to see if data was posted. If not, form is displayed. If yes, then go to step 2. 2. Validate ALL the posted data. The original code would stop on the first invalid piece of data. That is a major improvement in the code I provided. 3a. If validation passes, attempt to send the email. If successful go to confirmation page that then redirects. If send fails go to a friendly error page. 3b. If validation fails, display the form with the posted data The validation in the above process is the PHP validation. However, for users that have JavaScript enabled that should always pass since the form has JavaScript validation that will occur before the form is submitted. Now to address your questions: Changing the JavaScript validation to show an error on-sceen is simple enough. In fact, you can get really fancy with showing in-place errors next to each field. It's totally up to you how elaborate you want to make it. I made changes to the JS validatioin to show a simple alert and then display the errors on the page itself. You can remove the alert if need be. The reason I broke the code up into multiple files is for several reasons: 1. It is a best practice method. You should always break up logical sections of your code. Just as it is preferred to have your CSS in an external file so you can change the display for your site with one edit instead of having to esit each page individually. 2. Makes it easier to maintain. For example, I made the list of countries into an array insterad of writing out each <OPTION> tag directly in the form page. You can edit the list of countries by modifying that array. Or you could change to getting your listing of countries from a database or XML feed without changing your form. Also, if you wanted a confirmation or error page for the email submission you could do it much easier with having an external page than having to wade through all the code on one long page. If it were for my use I would have broken it up even further. I made some changes indicated below. Also, you ca see it all workign here http://damato.net/contact Note: I hard coded the path to the external js and css files on your site so I didn't have to copy them down. You should remove those hard-coded paths. index.php <?php //Load the countries list require('email_countries.php'); function is_email($email) { $formatTest = '/^[-\w+]+(\.[-\w+]+)*@[-a-z\d]{2,}(\.[-a-z\d]{2,})*\.[a-z]{2,6}$/i'; $lengthTest = '/^(.{1,64})@(.{4,255})$/'; return (preg_match($formatTest, $email) && preg_match($lengthTest, $email)); } if (isset($_POST['form_id'])) { //Create array variable for errors $errors = array(); $error_msg = ''; //Posted variables $Name = trim($_POST["Name"]); $Address = trim($_POST["Address"]); $Address2 = trim($_POST["Address2"]); $City = trim($_POST["City"]); $State = trim($_POST["State"]); $Country = trim($_POST["Country"]); $Zip = trim($_POST["Zip"]); $Phone = trim($_POST["Phone"]); $Email = trim($_POST["Email"]) ; //Validate the posted values if (empty($Name)) { $errors[] = "Name is required."; } if (empty($Address)) { $errors[] = "Address is required."; } if (empty($City)) { $errors[] = "City is required."; } if (empty($State)) { $errors[] = "State is required."; } if (!in_array($Country, $countries)) { $errors[] = "Country is required."; } if (empty($Email)) { $errors[] = "Email is required."; } else if (!is_email($Email)) { $errors[] = "Email is invalid."; } //Create error message if needed if (count($errors)>0) { $error_msg = "The following errors occured. Please correct and resubmit the form:<br />\n"; $error_msg .= "<ul><li>" . implode("</li>\n<li>", $errors) . "</li></ul>"; } else { //There were no errors send the data $recipient = "you@yourdomain.com"; $subject = "TEST SUBJECT"; $headers = 'From: <webmaster@example.com>' . "\r\n"; $forminfo = "Name: $Name\n"; $forminfo .= "Address: $Address\n"; $forminfo .= "Address2: $Address2\n"; $forminfo .= "City: $City\n"; $forminfo .= "State: $State\n"; $forminfo .= "Country: $Country\n"; $forminfo .= "Zip: $Zip\n"; $forminfo .= "Phone: $Phone\n"; $forminfo .= "Email: $Email\n"; $forminfo .= "Form Submitted: " . date('M d, Y') . "\n\n"; $formsend = mail("$recipient", "$subject", "$forminfo", "From: $email\r\nReply-to:$email"); //Create confirmation/error page if ($formsend) { $title = "Thank you"; $refresh = "<meta http-equiv=\"refresh\" content=\"5; URL=index.php?main_page=contact_us_1\">"; $content = "Thank you. You submission has been complete. Redirecting..."; } else //Problem sending email { $title = "Submission error"; $content = "There was a problem sending your submission."; $refresh = ""; } //Show email confirmation/error page require('email_confirm.php'); exit(); } } //Page was not posted or there was an error require('email_form.php'); ?> email_form.php <?php function createSelectOptions($options, $selectedOption) { foreach ($options as $option) { $selected = ($option == $selectedOption)? ' selected="selected"': ''; echo "<option value=\"$option\"$selected>$option</option>\n"; } } ?> <!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 Form</title> <link rel="stylesheet" type="text/css" href="http://www.stxmilling.com/view.css" media="all"> <script type="text/javascript" src="http://www.stxmilling.com/view.js"></script> <script type="text/javascript"> String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g,''); } function validEmail(emailStr) { //Return true/false for valid/invalid email formatTest = /^[\w`\-=~!#$%^&*'+{}|'/?]+(\.[\w`\-=~!#$%^&*'+{}|'/?]+)*@[-a-z\d]{2,}(\.[-a-z\d]{2,})*\.[a-z]{2,6}$/i lengthTest = /^(.{1,64})@(.{4,255})$/ return (formatTest.test(emailStr) && lengthTest.test(emailStr)); } function validateForm(formObj) { var errors = new Array(); if(formObj.Name.value.trim()=='') { errors[errors.length] = 'Name is required'; } if(formObj.Address.value.trim()=='') { errors[errors.length] = 'Address is required'; } if(formObj.City.value.trim()=='') { errors[errors.length] = 'City is required'; } if(formObj.State.value.trim()=='') { errors[errors.length] = 'State is required'; } if(formObj.Country.value.trim()=='') { errors[errors.length] = 'Country is required'; } if(formObj.Email.value.trim()=='') { errors[errors.length] = 'Email is required'; } else if(!validEmail(formObj.Email.value.trim())) { errors[errors.length] = 'Email is invalid'; } if(errors.length>0) { errorMsg = 'The following errors occured:\n'; errorMsg += '<ul><li>' + errors.join('</li><li>') + '</li></ul>'; document.getElementById('errors').innerHTML = errorMsg; alert('There were errors. Please correct and resubmit.'); return false; } return true; } </script> </head> <body id="main_body" > <br /><br /> <div id="form_container"> <div id="errors"><?php echo $error_msg; ?></div> <form id="form_14512" class="appnitro" method="post" action="" onsubmit="return validateForm(this)"> <div class="form_description"> <h2>Request A Brochure</h2> </div> <ul> <li id="li_1" > <label class="description" for="Name">* Name </label> <div> <input id="Name" name="Name" class="element text medium" type="text" maxlength="255" value="<?php echo $Name; ?>"/> </div> <p class="guidelines" id="guide_1"><small>Enter your name</small></p> </li> <li id="li_2" > <label class="description" for="element_2">* Mailing Address </label> <div> <input id="Address" name="Address" class="element text large" value="<?php echo $Address; ?>" type="text"> <strong><label for="Address">* Street Address</label></strong> </div> <div> <input id="Address2" name="Address2" class="element text large" value="<?php echo $Address2; ?>" type="text"> <label for="Address2">Address Line 2</label> </div> <div class="left"><strong> <input id="City" name="City" class="element text medium" value="<?php echo $City; ?>" type="text"> <strong><label for="City">* City</label></strong> </div> <div class="right"><strong> <input id="State" name="State" class="element text medium" value="<?php echo $State; ?>" type="text"> <label for="State">* State / Province / Region</label></strong> </div> <div class="left"><strong> <input id="Zip" name="Zip" class="element text medium" maxlength="15" value="<?php echo $Zip; ?>" type="text"> <strong><label for="Zip">* Postal / Zip Code</label></strong> </div> <div class="right"><strong> <select class="element select medium" id="Country" name="Country"> <option value="" selected="selected"></option> <?php createSelectOptions($countries, $Country); ?> </select> <strong><label for="Country">* Country</label></strong> </div> <p class="guidelines" id="guide_2"><small>Enter your mailing address</small></p> </li> <li id="li_3" > <label class="description" for="Phone">Phone Number </label> <div> <input id="Phone" name="Phone" class="element text medium" type="text" maxlength="255" value="<?php echo $Phone; ?>"/> </div> <p class="guidelines" id="guide_3"><small>Enter your phone number</small></p> </li> <li id="li_4" > <label class="description" for="Email">* Email </label> <div> <input id="Email" name="Email" class="element text medium" type="text" maxlength="255" value="<?php echo $Email; ?>"/> </div> <p class="guidelines" id="guide_4"><small>Enter your email address</small></p> </li> <li class="buttons"> <input type="hidden" name="form_id" value="14512" /> <input value="Submit form" type="submit" /> </li> </ul> </form> <div id="footer"></div> </div> </body> </html>
  22. 1. The URL you posted is not complete. Looks like part of the text after index. was replaced. 2. The "problem" you are having is related to your PHP code. Although you are asking for a JavaScript solution to validate before the data is posted, you still need to fix the PHP validation. The javascript validation is a nice to have feature, but you also need to validate server-side. I've made A LOT of changes. The page is called for displaying and processing the form, so if there is an error you can redisplay the form with the previosuly entered values. Here is the main page: <?php //Load the countries list require('email_countries.php'); function is_email($email) { $formatTest = '/^[-\w+]+(\.[-\w+]+)*@[-a-z\d]{2,}(\.[-a-z\d]{2,})*\.[a-z]{2,6}$/i'; $lengthTest = '/^(.{1,64})@(.{4,255})$/'; return (preg_match($formatTest, $email) && preg_match($lengthTest, $email)); } if (isset($_POST)) { //Create array variable for errors $errors = array(); $error_msg = ''; //Posted variables $Name = trim($_POST["Name"]); $Address = trim($_POST["Address"]); $Address2 = trim($_POST["Address2"]); $City = trim($_POST["City"]); $State = trim($_POST["State"]); $Country = trim($_POST["Country"]); $Zip = trim($_POST["Zip"]); $Phone = trim($_POST["Phone"]); $Email = trim($_POST["Email"]) ; //Validate the posted values if (empty($Name)) { $errors[] = "Name is required."; } if (empty($Address)) { $errors[] = "Address is required."; } if (empty($City)) { $errors[] = "City is required."; } if (empty($State)) { $errors[] = "State is required."; } if (!in_array($Country, $countries)) { $errors[] = "Country is required."; } if (empty($Email)) { $errors[] = "Email is required."; } else if (!is_email($Email)) { $errors[] = "Email is invalid."; } //Create error message if needed if (count($errors)>0) { $error_msg = "The following errors occured. Please correct and resubmit the form:<br />\n"; $error_msg .= "<ul><li>" . implode("</li>\n<li>", $errors) . "</li></ul>"; } else { //There were no errors send the data $recipient = "you@yourdomain.com"; $subject = "TEST SUBJECT"; $headers = 'From: <webmaster@example.com>' . "\r\n"; $forminfo = "Name: $Name\n"; $forminfo .= "Address: $Address\n"; $forminfo .= "Address2: $Address2\n"; $forminfo .= "City: $City\n"; $forminfo .= "State: $State\n"; $forminfo .= "Country: $Country\n"; $forminfo .= "Zip: $Zip\n"; $forminfo .= "Phone: $Phone\n"; $forminfo .= "Email: $Email\n"; $forminfo .= "Form Submitted: " . date('M d, Y') . "\n\n"; $formsend = mail("$recipient", "$subject", "$forminfo", "From: $email\r\nReply-to:$email"); //Create confirmation/error page if ($formsend) { $title = "Thank you"; $refresh = "<meta http-equiv=\"refresh\" content=\"5; URL=index.php?main_page=contact_us_1\">"; $content = "Thank you. You submission has been complete. Redirecting..."; } else //Problem sending email { $title = "Submission error"; $content = "There was a problem sending your submission."; $refresh = ""; } //Show email confirmation/error page require('email_confirm.php'); exit(); } } //Page was not posted or there was an error require('email_form.php'); ?> email_form.php <?php function createSelectOptions($options, $selectedOption) { foreach ($options as $option) { $selected = ($option == $selectedOption)? ' selected="selected"': ''; echo "<option value=\"$option\"$selected>$option</option>\n"; } } ?> <!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 Form</title> <link rel="stylesheet" type="text/css" href="view.css" media="all"> <script type="text/javascript" src="view.js"></script> <script type="text/javascript"> String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g,''); } function validEmail(emailStr) { //Return true/false for valid/invalid email formatTest = /^[\w`\-=~!#$%^&*'+{}|'/?]+(\.[\w`\-=~!#$%^&*'+{}|'/?]+)*@[-a-z\d]{2,}(\.[-a-z\d]{2,})*\.[a-z]{2,6}$/i lengthTest = /^(.{1,64})@(.{4,255})$/ return (formatTest.test(emailStr) && lengthTest.test(emailStr)); } function validateForm(formObj) { errors = new Array(); if(formObj.Name.value.trim()=='') { errors[errors.length] = 'Name is required'; } if(formObj.Address.value.trim()=='') { errors[errors.length] = 'Address is required'; } if(formObj.City.value.trim()=='') { errors[errors.length] = 'City is required'; } if(formObj.State.value.trim()=='') { errors[errors.length] = 'State is required'; } if(formObj.Country.value.trim()=='') { errors[errors.length] = 'Country is required'; } if(formObj.Email.value.trim()=='') { errors[errors.length] = 'Email is required'; } else if(!validEmail(formObj.Email.value.trim())) { errors[errors.length] = 'Email is invalid'; } if(errors.length>0) { errorMsg = 'The following errors occured:\n'; for (var i in errors) { errorMsg += ' - ' + errors[i] + '\n'; } alert(errorMsg); return false; } return true; } </script> </head> <body id="main_body" > <br /><br /> <?php echo $error_msg; ?> <div id="form_container"> <form id="form_14512" class="appnitro" method="post" action="" onsubmit="return validateForm(this)"> <div class="form_description"> <h2>Request A Brochure</h2> </div> <ul> <li id="li_1" > <label class="description" for="Name">* Name </label> <div> <input id="Name" name="Name" class="element text medium" type="text" maxlength="255" value="<?php echo $Name; ?>"/> </div> <p class="guidelines" id="guide_1"><small>Enter your name</small></p> </li> <li id="li_2" > <label class="description" for="element_2">* Mailing Address </label> <div> <input id="Address" name="Address" class="element text large" value="<?php echo $Address; ?>" type="text"> <strong><label for="Address">* Street Address</label></strong> </div> <div> <input id="Address2" name="Address2" class="element text large" value="<?php echo $Address2; ?>" type="text"> <label for="Address2">Address Line 2</label> </div> <div class="left"><strong> <input id="City" name="City" class="element text medium" value="<?php echo $City; ?>" type="text"> <strong><label for="City">* City</label></strong> </div> <div class="right"><strong> <input id="State" name="State" class="element text medium" value="<?php echo $State; ?>" type="text"> <label for="State">* State / Province / Region</label></strong> </div> <div class="left"><strong> <input id="Zip" name="Zip" class="element text medium" maxlength="15" value="<?php echo $Zip; ?>" type="text"> <strong><label for="Zip">* Postal / Zip Code</label></strong> </div> <div class="right"><strong> <select class="element select medium" id="Country" name="Country"> <option value="" selected="selected"></option> <?php createSelectOptions($countries, $Country); ?> </select> <strong><label for="Country">* Country</label></strong> </div> <p class="guidelines" id="guide_2"><small>Enter your mailing address</small></p> </li> <li id="li_3" > <label class="description" for="Phone">Phone Number </label> <div> <input id="Phone" name="Phone" class="element text medium" type="text" maxlength="255" value="<?php echo $Phone; ?>"/> </div> <p class="guidelines" id="guide_3"><small>Enter your phone number</small></p> </li> <li id="li_4" > <label class="description" for="Email">* Email </label> <div> <input id="Email" name="Email" class="element text medium" type="text" maxlength="255" value="<?php echo $Email; ?>"/> </div> <p class="guidelines" id="guide_4"><small>Enter your email address</small></p> </li> <li class="buttons"> <input type="hidden" name="form_id" value="14512" /> <input value="Submit form" type="submit" /> </li> </ul> </form> <div id="footer"></div> </div> </body> </html> email_confirm.php <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>$title</title>\n"; <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <?php echo $refresh; ?> <style type="text/css"> <!-- .style1 { font-size: 24px; font-weight: bold; } body { background-color: #ade4b0; } --> </style> </head> <body> <table width="100%" border="0" cellspacing="0" cellpadding="5"> <tr> <td><p align="left" class="style1"><?php echo $content; ?></p></td> </tr> </table> </body> </html> email_countries.php <?php $countries = array( 'Afghanistan', 'Albania', 'Algeria', 'Andorra', 'Antigua and Barbuda', 'Argentina', 'Armenia', 'Australia', 'Austria', 'Azerbaijan', 'Bahamas', 'Bahrain', 'Bangladesh', 'Barbados', 'Belarus', 'Belgium', 'Belize', 'Benin', 'Bhutan', 'Bolivia', 'Bosnia and Herzegovina', 'Botswana', 'Brazil', 'Brunei', 'Bulgaria', 'Burkina Faso', 'Burundi', 'Cambodia', 'Cameroon', 'Canada', 'Cape Verde', 'Central African Republic', 'Chad', 'Chile', 'China', 'Colombia', 'Comoros', 'Congo', 'Costa Rica', "Côte d'Ivoire", 'Croatia', 'Cuba', 'Cyprus', 'Czech Republic', 'Denmark', 'Djibouti', 'Dominica', 'Dominican Republic', 'East Timor', 'Ecuador', 'Egypt', 'El Salvador', 'Equatorial Guinea', 'Eritrea', 'Estonia', 'Ethiopia', 'Fiji', 'Finland', 'France', 'Gabon', 'Gambia', 'Georgia', 'Germany', 'Ghana', 'Greece', 'Grenada', 'Guatemala', 'Guinea', 'Guinea-Bissau', 'Guyana', 'Haiti', 'Honduras', 'Hong Kong', 'Hungary', 'Iceland', 'India', 'Indonesia', 'Iran', 'Iraq', 'Ireland', 'Israel', 'Italy', 'Jamaica', 'Japan', 'Jordan', 'Kazakhstan', 'Kenya', 'Kiribati', 'North Korea', 'South Korea', 'Kuwait', 'Kyrgyzstan', 'Laos', 'Latvia', 'Lebanon', 'Lesotho', 'Liberia', 'Libya', 'Liechtenstein', 'Lithuania', 'Luxembourg', 'Macedonia', 'Madagascar', 'Malawi', 'Malaysia', 'Maldives', 'Mali', 'Malta', 'Marshall Islands', 'Mauritania', 'Mauritius', 'Mexico', 'Micronesia', 'Moldova', 'Monaco', 'Mongolia', 'Montenegro', 'Morocco', 'Mozambique', 'Myanmar', 'Namibia', 'Nauru', 'Nepal', 'Netherlands', 'New Zealand', 'Nicaragua', 'Niger', 'Nigeria', 'Norway', 'Oman', 'Pakistan', 'Palau', 'Panama', 'Papua New Guinea', 'Paraguay', 'Peru', 'Philippines', 'Poland', 'Portugal', 'Puerto Rico', 'Qatar', 'Romania', 'Russia', 'Rwanda', 'Saint Kitts and Nevis', 'Saint Lucia', 'Saint Vincent and the Grenadines', 'Samoa', 'San Marino', 'Sao Tome and Principe', 'Saudi Arabia', 'Senegal', 'Serbia and Montenegro', 'Seychelles', 'Sierra Leone', 'Singapore', 'Slovakia', 'Slovenia', 'Solomon Islands', 'Somalia', 'South Africa', 'Spain', 'Sri Lanka', 'Sudan', 'Suriname', 'Swaziland', 'Sweden', 'Switzerland', 'Syria', 'Taiwan', 'Tajikistan', 'Tanzania', 'Thailand', 'Togo', 'Tonga', 'Trinidad and Tobago', 'Tunisia', 'Turkey', 'Turkmenistan', 'Tuvalu', 'Uganda', 'Ukraine', 'United Arab Emirates', 'United Kingdom', 'United States', 'Uruguay', 'Uzbekistan', 'Vanuatu', 'Vatican City', 'Venezuela', 'Vietnam', 'Yemen', 'Zambia', 'Zimbabwe' ); ?>[code]
  23. Use the followign tables: Members: ID--username--password watched: movieID--memberID--rating movies: ID--title--rating Then you can get a list of all the movies a member has watched (along with their rating as follows) SELECT movie.title, watched.rating FROM movies JOIN watched ON movies.id = watched.movieID JOIN members ON watched.memberID = members.ID WHERE member.username = '$username'
  24. if you mean combined them into the members table, I can't really think of a way to logically do that. I asked in case I may be misunderstanding something about what you are trying to achieve. Now one thing I am not sure of is do you track movies that members have watched IF they have not rated them? If so, then you don't need to track if they have watched the movie as you can simply deduce that by the movies they have rated. If you are tracking those separately you *could* possibly combine the watched and rating value for each member in a single table (movieID | watched | rating).
  25. No, I'm saying you want four tables: Members: ID--username--password movies: ID--title--rating watched: movieID--memberID member_rating movieID--memberID--member_rating In your current schema, how were you tracking multiple movies that a member had watched or multuple movies a member had rated? Anyway, with the above schema you could get a list of every movie a member had watched and/or rated with a query such as this SELECT * FROM movies LEFT JOIN watched ON watched.movieID = movies.ID LEFT JOIN rating ON rating.movieID = movies.ID JOIN members ON members.id = watched.memberID OR members.id = rating.memberID WHERE members.name = '$memberName'
×
×
  • 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.