Jump to content

djcochran

Members
  • Posts

    25
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

djcochran's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I guess it won't run at all. Like...when I click the 'Checkout' button...the alert message doesn't appear.
  2. I recently converted all my html pages into php pages, and in doing so, well...I can't seem to figure out how to get the javascript function checkout() to work at all! It used too...now it doesn't. I know this may be a lot to go through, but if anyone would mind looking through and maybe seeing what could be the problem? Thanks! <?php session_start(); $file = fopen("template2.data", "r"); while(!feof($file)) { $line = fgets($file); if(preg_match("/@@CONTENT_HERE@@/", $line, $dummyarray)){ print<<<END <script type="text/javascript"> function changeLink(targetDiv){ targetDiv.style.color = "#FFFF00"; } function revertLink(targetDiv){ targetDiv.style.color = "blue"; } </script> <script type="text/javascript"> function set_cookie (name, value, exp_y, exp_m, exp_d, path, domain, secure){ var cookie_string = name + "=" + escape (value); if (exp_y){ var expires = new Date ( exp_y, exp_m, exp_d ); cookie_string += "; expires=" + expires.toGMTString(); } if(path){ cookie_string += "; path=" + escape (path); } if(domain){ cookie_string += "; domain=" + escape (domain); } if (secure){ cookie_string += "; secure"; } document.cookie = cookie_string; } </script> <script type="text/javascript"> function checkOut(){ var cartContentDisplay = "Shopping Cart Contents:\n" var cookieArray=document.cookie.split(';'); var cookieIndex=0; for(var i=1; i<cookieArray.length;++i){ var cookiePair=cookieArray[i].split('='); cartContentDisplay = cartContentDisplay + "\nProduct Number: " +cookiePair[cookieIndex] +"\nQuantity: " +cookiePair[cookieIndex+1] +"\n\n"; } alert(cartContentDisplay); } </script> <script type="text/javascript"> var quantityRe = /^\d+$/; function quantityAdd(){ var answer=confirm("Update shopping cart?") if(answer==true){ var fieldArray=document.products.getElementsByTagName("input"); for(i=0; i < fieldArray.length; ++i){ if(fieldArray[i].type=="text"){ if(!quantityRe.test(fieldArray[i].value) && fieldArray[i].value != ""){ alert("Please check the input for item #" + fieldArray[i].name); return; } } } for(j=0; j < fieldArray.length; ++j){ if(fieldArray[j].type=="text"){ if(fieldArray[j].value == ""){ fieldArray[j].value = 0; } document.cart.cartTotal.value = eval(document.cart.cartTotal.value) + eval(fieldArray[j].value); var totalCartContents=get_cookie("cartTotal"); set_cookie("cartTotal", totalCartContents+eval(fieldArray[j].value)); if(fieldArray[j].value > 0){ var currentCartContents = get_cookie(fieldArray[j].name); set_cookie(fieldArray[j].name, eval(fieldArray[j].value)+currentCartContents); } } } } else{} for(k=0; k < fieldArray.length; ++k){ if(fieldArray[k].type=="text"){ fieldArray[k].value = 0; } } } </script> <script type="text/javascript"> function get_cookie(cookie_name){ var results = document.cookie.match ( '(^| ?' + cookie_name + '=([^;]*)(;|$)' ); if(results) return eval((unescape(results[2]))); else return null; } </script> <DIV CLASS="body"> <FORM NAME="products"> <TABLE BORDER="1"> <TR> <TD WIDTH="50px" HEIGHT="50px"><IMG WIDTH="175px" HEIGHT="175px" SRC="picscript.php?pnum=10117"></TD> <TD WIDTH="1500px" HEIGHT="50px"> Product Name: Slinky <BR><I>The greatest toy ever created. Try flipping it down the stairs for extra excitement!</I> <BR><BR>Price: <FONT COLOR="#FF3300">$1.99 </FONT> + S/H <BR>Number in Stock: 1000 <BR>Product #10117 <BR><P ALIGN="RIGHT">Quantity: <INPUT TYPE="text" NAME=10117 MAXLENGTH="5" STYLE="width:40px;" VALUE="0" CLASS="textfield"></P> </TD> </TR> <TR> <TD WIDTH="50px" HEIGHT="50px"><IMG WIDTH="175px" HEIGHT="175px" SRC="images/10123.jpg"></TD> <TD WIDTH="1500px" HEIGHT="50px"> Product Name: The Blaze Broom <BR><I>Sweep your kitchen with the speed of BlazeĀ®!</I> <BR><BR>Price: <FONT COLOR="#FF3300">$9.99 </FONT> + S/H <BR>Number in Stock: 23 <BR>Product #10123 <BR><P ALIGN="RIGHT">Quantity: <INPUT TYPE="text" NAME=10123 MAXLENGTH="5" STYLE="width:40px;" VALUE="0" CLASS="textfield"></P> </TD> </TR> <TR> <TD WIDTH="50px" HEIGHT="50px"><IMG WIDTH="175px" HEIGHT="175px" SRC="images/10543.jpg"></TD> <TD WIDTH="1500px" HEIGHT="50px"> Product Name: A White T-Shirt <BR><I>100% natural cotton. The perfect thing to wear whenever you don't have anything else to wear!</I> <BR><BR>Price: <FONT COLOR="#FF3300">$5.99 </FONT> + S/H <BR>Number in Stock: 54 <BR>Product #10543 <BR><P ALIGN="RIGHT">Quantity: <INPUT TYPE="text" NAME=10543 MAXLENGTH="5" STYLE="width:40px;" VALUE="0" CLASS="textfield"></P> </TD> </TR> <TR> <TD WIDTH="50px" HEIGHT="50px"><IMG WIDTH="175px" HEIGHT="175px" SRC="images/10225.jpg"></TD> <TD WIDTH="1500px" HEIGHT="50px"> Product Name: Porcelain German Shepherd <BR><I>The perfect addition to any bookshelf.</I> <BR><BR>Price: <FONT COLOR="#FF3300">$19.99 </FONT> + S/H <BR>Number in Stock: 3 <BR>Product #10225 <BR><P ALIGN="RIGHT">Quantity: <INPUT TYPE="text" NAME=10225 MAXLENGTH="5" STYLE="width:40px;" VALUE="0" CLASS="textfield"></P> </TD> </TR> <TR> <TD WIDTH="50px" HEIGHT="50px"><IMG WIDTH="175px" HEIGHT="175px" SRC="images/10318.jpg"></TD> <TD WIDTH="1500px" HEIGHT="50px"> Product Name: Nintendo Entertainment System <BR><I>Technology meets fun! Game cartridges not included.</I> <BR><BR>Price: <FONT COLOR="#FF3300">$39.99 </FONT> + S/H <BR>Number in Stock: 10 <BR>Product #10318 <BR><P ALIGN="RIGHT">Quantity: <INPUT TYPE="text" NAME=10318 MAXLENGTH="5" STYLE="width:40px;" VALUE="0" CLASS="textfield"></P> </TD> </TR> <TR> <TD WIDTH="50px" HEIGHT="50px"><IMG WIDTH="175px" HEIGHT="175px" SRC="images/10505.jpg"></TD> <TD WIDTH="1500px" HEIGHT="50px"> Product Name: Grab Bag <BR><I>A mysterious assortment of odds and ends. Great for parties!</I> <BR><BR>Price: <FONT COLOR="#FF3300">0.99 </FONT> + S/H <BR>Number in Stock: 9999 <BR>Product #10505 <BR><P ALIGN="RIGHT">Quantity: <INPUT TYPE="text" NAME=10505 MAXLENGTH="5" STYLE="width:40px;" VALUE="0" CLASS="textfield"></P> </TD> </TR> <TR> <TD WIDTH="50px" HEIGHT="50px"><IMG WIDTH="175px" HEIGHT="175px" SRC="images/10353.jpg"></TD> <TD WIDTH="1500px" HEIGHT="50px"> Product Name: SuperMote <BR><I>Never hit the wrong button ever again with ridiculously large remote control. A great gift for old people!</I> <BR><BR>Price: <FONT COLOR="#FF3300">$12.99 </FONT> + S/H <BR>Number in Stock: 49 <BR>Product #10353 <BR><P ALIGN="RIGHT">Quantity: <INPUT TYPE="text" NAME=10353 MAXLENGTH="5" STYLE="width:40px;" VALUE="0" CLASS="textfield"></P> </TD> </TR> <TR> <TD WIDTH="50px" HEIGHT="50px"><IMG WIDTH="175px" HEIGHT="175px" SRC="images/10369.jpg"></TD> <TD WIDTH="1500px" HEIGHT="50px"> Product: Shower Caps (AMOUNT-GROSS) <BR><I>One order of these caps can last you a lifetime! Comes in three fun colors!</I> <BR><BR>Price: <FONT COLOR="#FF3300">$2.99 </FONT> + S/H <BR>Number in Stock: 144000 <BR>Product #10369 <BR><P ALIGN="RIGHT">Quantity: <INPUT TYPE="text" NAME=10369 MAXLENGTH="5" STYLE="width:40px;" VALUE="0" CLASS="textfield"></P> </TD> </TR> <TR> <TD WIDTH="50px" HEIGHT="50px"><IMG WIDTH="175px" HEIGHT="175px" SRC="images/10875.jpg"></TD> <TD WIDTH="1500px" HEIGHT="50px"> Product Name: Sonic Earz <BR><I>You will be able to hear a gnat pass gas with these ultra-powered hearing enhancers!</I> <BR><BR>Price: <FONT COLOR="#FF3300">$49.99 </FONT> + S/H <BR>Number in Stock: 20 <BR>Product #10875 <BR><P ALIGN="RIGHT">Quantity: <INPUT TYPE="text" NAME=10875 MAXLENGTH="5" STYLE="width:40px;" VALUE="0" CLASS="textfield"></P> </TD> </TR> <TR> <TD WIDTH="50px" HEIGHT="50px"><IMG WIDTH="175px" HEIGHT="175px" SRC="images/10299.jpg"></TD> <TD WIDTH="1500px" HEIGHT="50px"> Product Name: The Swiss Mister Pro <BR><I>Contains every tool for every situation.</I> <BR><BR>Price: <FONT COLOR="#FF3300">$129.99 </FONT> + S/H <BR>Number in Stock: 20 <BR>Product #10299 <BR><P ALIGN="RIGHT">Quantity: <INPUT TYPE="text" NAME=10299 MAXLENGTH="5" STYLE="width:40px;" VALUE="0" CLASS="textfield"></P> </TD> </TR> </TABLE> <P ALIGN="RIGHT"><INPUT TYPE="button" NAME="addButton" ONCLICK="javascript:quantityAdd()" VALUE="Add to Shopping Cart"><INPUT TYPE="button" NAME="checkoutButton" ONCLICK="javascript:checkOut()" VALUE="Checkout"></P> <BR><BR> </FORM> </DIV> END; }else if(preg_match("/@@LOGGED_IN@@/", $line, $dummyarray)){ // look for another special marker if(isset($_SESSION['name'])){ // check if session variable that indicate user is logged in has been set echo "&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp User is logged in"; }else{ echo "&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp User is not logged in"; } }else{ echo $line; }; // end else }; // end while ?>
  3. sorry for the double post
  4. Hmm...well everything is in the correct folder (I assume). I've tried moving some files around (like moving index.php up one folder) and accessing it, but it wouldn't let me because the two files were not in the same directory. So I'm pretty sure that's working right...
  5. I discovered a program online that lets you view HTML and PHP source code, but I'm having a problem with it. I'm supposed to upload the file sourceviewer.php to my server, and then open that file in my browser. It then shows a text box where you enter the url of the page you want to view the source of and it is supposed to show it to you. I'm having a problem with that. It says you need to have sourceviewer.php in the same directory as the pages you want to view (and I do!) but I can't get it to work. For example, the url for it in http://cs-sun2000.uscupstate.edu/~student5/sourceviewer.php and I try to view the file http://cs-sun2000.uscupstate.edu/~student5/index.php, but I get this message "The file to be viewed must be located on the server hosting cs-sun2000.uscupstate.edu. The file /~student5/index.php does not appear to be a valid file on this host." I've also tried modifying the php code in sourceviewer.php to include other directories (I even tried adding /export/home/student5 as it is in the web server), but still nothing. Anyone ever worked with this or know what to do? I would really like to use this program. SourceViewer Website - http://www.softswot.com/sourcehelp.php
  6. Nevermind. I found the syntax error, but now I have another problem. It enters the data into the table, but for some reason, it's all blank. It doesn't show anything but white space in the table.
  7. Would anyone mind giving this a once over and helping me figure out what my error is? I've been trying different stuff for the past day and a half and can't figure it out.
  8. What exactly do you mean? I'm fairly new at this. Well...I'm really new at this :-\
  9. I've read over it, and I can't seem to find any misspellings or anything. That's what fatal errors usually refer to, right? Syntax kind of stuff?
  10. I think so. I'm using database student5 and inserting a new record into the table cusinfo. I even tried not specifying which columns to put it in (just create insert a new one with all the info) and I still got that error.
  11. I'm sorry. I see it now. I had something in the way blocking the text. I got this error message... Fatal Error: SQL in /export/home/student5/html/join.php on line 1224. This is line 1224 $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR);
  12. I tried adding echo mysql_error($result); and running it, but it didn't do anything. It just sent me back to the page. And it still didn't update the cusinfo table. Is my php code not being executed or something??
  13. I don't understand. This isn't doing anything. I keep trying to fill in the form, but when I hit submit and check my mysql table, nothing has happened. What's going on? *I removed a lot of stuff, like state names and whatnot to save space. <?php $file = fopen("template.data", "r"); while(!feof($file)) { $line = fgets($file); if(preg_match("/@@CONTENT_HERE@@/", $line, $dummyarray)){ print<<<END <script type="text/javascript"> var emailRe=/^.+@.+\..{2,3}$/; var zipCodeRe=/^[0-9][0-9][0-9][0-9][0-9]$/; var telephoneRe=/^[\(]?(\d{3})[\)]?[-\.]?(\d{3})[-\.]?(\d{4})$/; function validate_form(){ valid = true; if(document.join.lastName.value == ""){ alert("Please provide your last name."); valid = false; } if(document.join.firstName.value == ""){ alert("Please provide your first name."); valid = false; } if(document.join.addressOne.value == ""){ alert("Please provide your address."); valid = false; } if(document.join.city.value == ""){ alert("Please provide your city name."); valid = false; } if(document.join.state.value == ""){ alert("Please select your state."); valid = false; } if(document.join.country.value == ""){ alert("Please select your country."); valid = false; } if(!zipCodeRe.test(document.join.zipCode.value)){ alert("Please provide a valid zip code."); valid = false; } if(!telephoneRe.test(document.join.phoneNumber.value)){ alert("Please provide a valid telephone number."); valid = false; } if(!emailRe.test(document.join.emailAddress.value)){ alert("Please provide a valid email address."); valid = false; } if(document.join.emailAddress.value != document.join.emailVerify.value){ alert("Email addresses do not match!"); valid = false; } if(document.join.password.value.length < 6){ alert("Password must be at least six characters long."); valid = false; } if(document.join.password.value != document.join.passwordVerify.value){ alert("Passwords do not match!"); valid = false; } if(document.join.secretQuestion.value == ""){ alert("Please provide your secret question."); valid = false; } if(document.join.secretQuestionAnswer.value == ""){ alert("Please provide answer to secret question."); valid = false; } return valid; } </script> </DIV> <DIV CLASS="body"> <FORM NAME="join" ACTION="http://cs-sun2000.uscupstate.edu/~student5/join.php" METHOD="POST" onsubmit="return validate_form();"> <TABLE> <TR> <TD>Last Name: </TD> <TD> <INPUT TYPE="text" NAME=lastName MAXLENGTH="20" VALUE="" CLASS="textfield"> </TD> </TR> <TR> <TD>First Name: </TD> <TD> <INPUT TYPE="text" NAME=firstName MAXLENGTH="25" VALUE="" CLASS="textfield"> </TD> </TR> <TR> <TD>Address One: </TD> <TD> <INPUT TYPE="text" NAME="addressOne" MAXLENGTH="32" VALUE="" CLASS="textfield"> </TD> </TR> <TR> <TD>Address Two: </TD> <TD> <INPUT TYPE="text" NAME="addressTwo" MAXLENGTH="32" VALUE="" CLASS="textfield"> </TD> </TR> <TR> <TD>City: </TD> <TD> <INPUT TYPE ="text" NAME="city" MAXLENGTH="32" VALUE="" CLASS="textfield"> </TD> </TR> <TR> <TD>State: </TD> <TD> <SELECT NAME="state" CLASS="textfield"> <OPTION VALUE="">(STATE) </OPTION> <OPTION VALUE="AL"> ALABAMA </OPTION></SELECT> </TD> </TR> <TR> <TD>Country: </TD> <TD> <SELECT NAME="country" CLASS="textfield"> <OPTION VALUE="">(COUNTRY)</OPTION> <OPTION VALUE="ANDORRA"> ANDORRA </OPTION></SELECT> </TD> </TR> <TR> <TD>Zip Code: </TD> <TD> <INPUT TYPE="text" NAME="zipCode" MAXLENGTH="10" VALUE="" CLASS="textfield"> </TD> </TR> <TR> <TD>Telephone: </TD> <TD> <INPUT TYPE="text" NAME="phoneNumber" MAXLENGTH="16" VALUE="" CLASS="textfield"><I><FONT SIZE="2">Ex. (555)123-4567 or 555-123-1234</FONT></I> </TD> </TR> <TR> <TD>Email: </TD> <TD> <INPUT TYPE="text" NAME="emailAddress" MAXLENGTH="100" VALUE="" CLASS="textfield"><I><FONT SIZE="2">Ex. emailname@xxxxx.com</FONT></I></TD> </TR> <TR> <TD>Verify Email: </TD> <TD> <INPUT TYPE="text" NAME="emailVerify" MAXLENGTH="100" VALUE="" CLASS="textfield"> </TD> </TR> <TR> <TD>Password: </TD> <TD> <INPUT TYPE="password" NAME="password" MAXLENGTH="64" VALUE="" CLASS="textfield"><I><FONT SIZE="2">Password must contain at least six characters.</FONT></I> </TD> </TR> <TR> <TD>Verify Password: </TD> <TD> <INPUT TYPE="password" NAME="passwordVerify" MAXLENGTH="64" VALUE="" CLASS="textfield"> </TD> </TR> <TR> <TD>Secret Question: </TD> <TD> <INPUT TYPE="text" NAME="secretQuestion" MAXLENGTH="100" STYLE="width:500px"; VALUE="" CLASS="textfield"><BR><I><FONT SIZE="2">Enter a question to be asked in case you forget your paswsword. (MAX LENGTH = 100 characters)</FONT></I></TD> </TR> <TR> <TD>Answer to Secret Question: </TD> <TD> <INPUT TYPE="text" NAME="secretQuestionAnswer" MAXLENGTH="100" STYLE="width:500px"; VALUE="" CLASS="textfield"><BR><I><FONT SIZE="2">Enter the answer to your secret question. (MAX LENGTH = 100 characters)</FONT></I> </TD> </TR> <TR> <TD> <BR><BR><INPUT TYPE="submit" NAME="send" VALUE="Submit"> <INPUT TYPE="reset" VALUE="Reset"> </TD> </TR> </TABLE> </FORM> </DIV> END; }else if(preg_match("/@@LOGGED_IN@@/", $line, $dummyarray)){ // look for another special marker if(isset($_SESSION['name'])){ // check if session variable that indicate user is logged in has been set echo "User is logged in"; }else{ echo "User is not logged in"; } }else{ echo $line; }; // end else }; // end while ?> <?php /**** Dealing with the database ****/ // connect to db $conn = mysql_connect('localhost','xxxx','xxxx') or trigger_error("SQL", E_USER_ERROR); $db = mysql_select_db('student5',$conn) or trigger_error("SQL", E_USER_ERROR); // INSERT: if we have a name to add... if($_POST['lastName']) // little bit of cleaning... $lastname = mysql_real_escape_string($_POST['lastName']); // insert new name into table if($_POST['firstName']) // little bit of cleaning... $firstname = mysql_real_escape_string($_POST['firstName']); // insert new name into table if($_POST['addressOne']) // little bit of cleaning... $addressOne = mysql_real_escape_string($_POST['addressOne']); // insert new name into table if($_POST['addressTwo']) // little bit of cleaning... $addressTwo = mysql_real_escape_string($_POST['addressTwo']); // insert new name into table if($_POST['city']) // little bit of cleaning... $city = mysql_real_escape_string($_POST['city']); // insert new name into table if($_POST['state']) // little bit of cleaning... $state = mysql_real_escape_string($_POST['state']); // insert new name into table if($_POST['country']) // little bit of cleaning... $country = mysql_real_escape_string($_POST['country']); // insert new name into table if($_POST['zipCode']) // little bit of cleaning... $zipcode = mysql_real_escape_string($_POST['zipCode']); // insert new name into table if($_POST['phoneNumber']) // little bit of cleaning... $phonenumber = mysql_real_escape_string($_POST['phoneNumber']); // insert new name into table if($_POST['emailAddress']) // little bit of cleaning... $emailaddress = mysql_real_escape_string($_POST['emailAddress']); // insert new name into table if($_POST['password']) // little bit of cleaning... $password = mysql_real_escape_string($_POST['password']); // insert new name into table if($_POST['secretQuestion']) // little bit of cleaning... $secretquestion = mysql_real_escape_string($_POST['secretQuestion']); // insert new name into table if($_POST['secretAnswer']) // little bit of cleaning... $secretanswer = mysql_real_escape_string($_POST['secretAnswer']); // insert new name into table $sql = "INSERT INTO cusinfo (cnum, last_Name, first_Name, address_One, address_Two, city, state, country, zip_Code, phone_Number, email_Address, password, secret_Question, secret_Answer) VALUES ('','$lastname', $firstname', '$addressone', '$addresstwo', '$city', '$state', '$country', '$zipcode', '$phonenumber', '$emailaddress', '$password', '$secretquestion','$secretanswer')"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); ?> The php stuff is the top and bottom. Everything in the middle is just the form/html. Also, quick question...do I need to use something special for getting the password instead of just mysql_real_escape_string?
  14. I'm having trouble figuring out how to get the data I want to submit to my mysql table out of the html form. I'm trying to get the stuff people type in the textboxes/drop-down list and put it into it's corresponding table. <?php /**** Dealing with the database ****/ // connect to db $conn = mysql_connect('localhost','student5','up8833') or trigger_error("SQL", E_USER_ERROR); $db = mysql_select_db('student5',$conn) or trigger_error("SQL", E_USER_ERROR); // INSERT: if we have a name to add... if($_POST['name']) { // little bit of cleaning... $name = mysql_real_escape_string($_POST['name']); // insert new name into table $sql = "INSERT INTO info (name) VALUES ('','$name')"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); } // end if ?> That's the PHP code. Now...say I want 'name' to be the info from document.form1.lastName.value? How do I get that into there? Can I just put it where 'name' is in the if($_POST[]) thing or what?
  15. I've created a simple hit counter on for my site, but I've noticed a strange problem. For some reason, it will increment correctly in IE, but in Firefox it sometimes goes up by 2. Why is it doing this?? <?php // Connects to your Database mysql_connect("localhost", "xxxxx", "xxxxx") or die(mysql_error()); mysql_select_db("student5") or die(mysql_error()); //Adds one to the counter mysql_query("UPDATE counters SET num=num + 1 WHERE name='count'") or die("Update query failed: " . mysql_error()); //Retreives the current count $query = "SELECT num FROM counters"; $result = mysql_query($query) or die("Select query failed: " . mysql_error()); $count = mysql_fetch_row(mysql_query("SELECT num FROM counters WHERE name='count'")); ?>
×
×
  • 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.