Jump to content

twilitegxa

Members
  • Posts

    1,020
  • Joined

  • Last visited

Everything posted by twilitegxa

  1. Got it figured out guys, thanks! <a href=upload/" . $_FILES["file"]["name"] . ">" . $_FILES["file"]["name"] . "</a>
  2. Can someone help me in renaming an uploaded file with parameters from the input fields named firstname and lastname? I would like to name each uploaded file with the firstname and lastname along with a random number and then the file extension, but I am having trouble getting it right. Here is what I have so far: <?php $firstname = ""; $lastname = ""; $address = ""; $city = ""; $state = ""; $zip = ""; $phone = ""; $position = ""; ?> <!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>KulaE_WDP4451_U2IP</title> </head> <body> <form action="process_U2IP.php" method="post" enctype="multipart/form-data"> <h3>Please fill out the form below and upload your resume to apply for a position within our company:</h3> <table> <tr> <td><label for="firstname"><b>First Name*</b></label></td> <td><input name="firstname" type="text" size="20" id="firstname" value="<?php echo $lastname; ?>" /></td> </tr> <tr> <td><label for="lastname"><b>Last Name*</b></label></td> <td><input name="lastname" type="text" size="20" id="lastname" value="<?php echo $lastname; ?>" /></td> </tr> <tr> <td><label for="address"><b>Address*</b></label></td> <td><input name="address" type="text" size="20" id="address" value="<?php echo $address; ?>" /></td> </tr> <tr> <td><label for="city"><b>City*</b></label></td> <td><input name="city" type="text" size="20" id="city" value="<?php echo $city; ?>" /></td> </tr> <tr> <td><label for="state"><b>State*</b></label></td> <td><input name="state" type="text" size="20" id="state" value="<?php echo $state; ?>" /></td> </tr> <tr> <td><label for="zip"><b>Zip*</b></label></td> <td><input name="zip" type="text" size="20" id="zip" value="<?php echo $zip; ?>" /></td> </tr> <tr> <td><label for="phone"><b>Phone*</b></label></td> <td><input name="phone" type="text" size="20" id="phone" value="<?php echo $phone; ?>" /></td> </tr> <tr> <td><label for="position"><b>Position*</b></label></td> <td><input name="position" type="text" size="20" id="position" value="<?php echo $position; ?>" /></td> </tr> <tr> <td><b>Upload Resume*</b></td> <td><input type="file" name="file" id="file" /> </td> </tr> <tr> <td colspan="2"><p><i>Your information will not be sold or shared with others.</i></p></td> </tr> <tr> <td colspan="2"><p style="color: red;">* denotes required field</p></td> </tr> <tr> <td colspan="2" align="center"><input type="hidden" name="submitted" value="1" /> <input type="submit" value="Submit" /> <input type="reset" name="reset" value="Reset" /></td> </tr> </table> </form> </body> </html> <?php if (@$_POST['submitted']){ $firstname = (@$_POST['firstname']); $lastname = (@$_POST['lastname']); $address = (@$_POST['address']); $city = (@$_POST['city']); $state = (@$_POST['state']); $zip = (@$_POST['zip']); $phone = (@$_POST['phone']); $position = (@$_POST['position']); $file = (@$_POST['file']); if (get_magic_quotes_gpc()){ $firstname = stripslashes($firstname); $lastname = stripslashes($lastname); $address = stripslashes($address); $city = stripslashes($city); $state = stripslashes($state); $zip = stripslashes($zip); $phone = stripslashes($phone); $position = stripslashes($position); } $error_msg=array(); if ($firstname==""){ $error_msg[]="Please enter your first name"; } if(!preg_match("/^\b[a-zA-Z]+\b$/", $firstname)){ $error_msg[]="First Name can only contain letters"; } if ($lastname==""){ $error_msg[]="Please enter your last name"; } if(!preg_match("/^\b[a-zA-Z]+\b$/", $lastname)){ $error_msg[]="Last Name can only contain letters"; } if ($address==""){ $error_msg[]="Please enter your address"; } if(!preg_match('/^[a-z0-9 ]*$/i', $address)){ $error_msg[]="Address can only contain numbers, letters and spaces"; } if ($city==""){ $error_msg[]="Please enter your city"; } if (!preg_match("/^\b[a-zA-Z]+\b$/", $city)){ $error_msg[]="City can only contain letters"; } if ($state==""){ $error_msg[]="Please enter your state"; } if (strlen($state)<>2){ $error_msg[]="State can only contain 2 letters; use state abbreviation"; } if (!preg_match("/^\b[a-zA-Z]+\b$/", $state)){ $error_msg[]="State can only contain letters"; } if ($zip==""){ $error_msg[]="Please enter your zip code"; } if (strlen($zip)<>5){ $error_msg[]="Zip code can only contain 5 digits"; } if(!is_numeric($zip)){ $error_msg[]="Zip code must contain only numbers"; } if ($phone==""){ $error_msg[]="Please enter your phone number"; } if (strlen($phone)<>10){ $error_msg[]="Phone number can only contain 10 digits"; } if(!is_numeric($phone)){ $error_msg[]="Phone number must contain only numbers"; } if ($position==""){ $error_msg[]="Please enter your desired position"; } if(!preg_match('/^[a-z0-9 ]*$/i', $position)){ $error_msg[]="Position can only contain numbers, letters and spaces"; } if (file_exists("upload/" . $_FILES["file"]["name"])) { $error_msg[]= $_FILES["file"]["name"] . " already exists"; } if ((($_FILES["file"]["type"] != "document/msword") || ($_FILES["file"]["type"] != "document/pdf")) && ($_FILES["file"]["size"] > 20000)) { $error_msg[]= "Uploaded file can only be in MSWord or PDF format and can only be under 20KB in size"; } } if ($error_msg){ $display_errors = "<h3>There were errors in your submission.</h3> <p>Please review the following errors, press the Back button on your browser, and make corrections before re-submitting.</p> <ul style=color:red>\n"; foreach ($error_msg as $err){ $display_errors .= "<li>".$err."</li>\n"; } $display_errors .= "</ul>\n"; } if (!$error_msg){ echo " <h3>Thank you for applying! Applicants we are interested in interviewing will be contacted within 48 hours.</h3> <p>You have submitted the following information:</p> <table> <tr> <td><b>First Name:</b></td> <td>$firstname</td> </tr> <tr> <td><b>Last Name:</b></td> <td>$lastname</td> </tr> <tr> <td><b>Address:</b></td> <td>$address</td> </tr> <tr> <td><b>City:</b></td> <td>$city</td> </tr> <tr> <td><b>State:</b></td> <td>$state</td> </tr> <tr> <td><b>Zip Code:</b></td> <td>$zip</td> </tr> <tr> <td><b>Phone Number:</b></td> <td>$phone</td> </tr> <tr> <td><b>Position Desired:</b></td> <td>$position</td> </tr>"; move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); echo "<tr> <td><b>Uploaded File:</b></td> <td><a href=upload/" . $_FILES["file"]["name"] . ">" . $_FILES["file"]["name"] . "</a></td> </tr> </table>"; exit(); } echo $display_errors; ?> I found the following help online, but I can't get it right. Can anyone help? <?php //This function separates the extension from the rest of the file name and returns it function findexts ($filename) { $filename = strtolower($filename) ; $exts = split("[/\\.]", $filename) ; $n = count($exts)-1; $exts = $exts[$n]; return $exts; } //This applies the function to our file $ext = findexts ($_FILES['uploaded']['name']) ; //This line assigns a random number to a variable. You could also use a timestamp here if you prefer. $ran = rand () ; //This takes the random number (or timestamp) you generated and adds a . on the end, so it is ready of the file extension to be appended. $ran2 = $ran."."; //This assigns the subdirectory you want to save into... make sure it exists! $target = "images/"; if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "The file has been uploaded as ".$ran2.$ext; } else { echo "Sorry, there was a problem uploading your file."; } ?>
  3. Thanks for all your help. I figured out away to get it all working. Thanks so much for all the help!
  4. Well, I added the session to both pages and named the session variables like you suggested, and it works! The only problem I'm getting is when I type something into my first field, name, I was trying to write a validation that only allowed letters and spaces, and when I typed in some other characters, like $%^, it seemed to work for those, saying the error message whenever one was typed, but if I refresh the page, and/or use my reset button, they sometimes are still slipping through to the next page. Any suggestions? Here is what I have currently: <?php session_start(); $name = ""; $address = ""; $city = ""; $state = ""; $zip = ""; $phone = ""; $position = ""; $display_errors = ""; if (@$_POST['submitted']){ $name = (@$_POST['name']); $address = (@$_POST['address']); $city = (@$_POST['city']); $state = (@$_POST['state']); $zip = (@$_POST['zip']); $phone = (@$_POST['phone']); $position = (@$_POST['position']); if (get_magic_quotes_gpc()){ $name = stripslashes($name); $address = stripslashes($address); $city = stripslashes($city); $state = stripslashes($state); $zip = stripslashes($zip); $phone = stripslashes($phone); $position = stripslashes($position); } $error_msg=array(); if ($name==""){ $error_msg[]="Please enter your name"; } if(!preg_match('/^[a-z ]*$/i', $name)){ $error_msg[]="Name can only contain letters and spaces"; } if ($address==""){ $error_msg[]="Please enter your address"; } if(!preg_match('/^[a-z0-9 ]*$/i', $address)){ $error_msg[]="Address can only contain numbers, letters and spaces"; } if ($city==""){ $error_msg[]="Please enter your city"; } if (!preg_match("/^\b[a-zA-Z]+\b$/", $city)){ $error_msg[]="City can only contain letters"; } if ($state==""){ $error_msg[]="Please enter your state"; } if (strlen($state)<>2){ $error_msg[]="State can only contain 2 letters; use state abbreviation"; } if (!preg_match("/^\b[a-zA-Z]+\b$/", $state)){ $error_msg[]="State can only contain letters"; } if ($zip==""){ $error_msg[]="Please enter your zip code"; } if (strlen($zip)<>5){ $error_msg[]="Zip code can only contain 5 digits"; } if(!is_numeric($zip)){ $error_msg[]="Zip code must contain only numbers"; } if ($phone==""){ $error_msg[]="Please enter your phone number"; } if (strlen($phone)<>10){ $error_msg[]="Phone number can only contain 10 digits"; } if(!is_numeric($phone)){ $error_msg[]="Phone number must contain only numbers"; } if ($position==""){ $error_msg[]="Please enter your desired position"; } if(!preg_match('/^[a-z0-9 ]*$/i', $position)){ $error_msg[]="Position can only contain numbers, letters and spaces"; } if ($error_msg){ $display_errors = "<ul style=color:red>\n"; foreach ($error_msg as $err){ $display_errors .= "<li>".$err."</li>\n"; } $display_errors .= "</ul>\n"; } if (!$error_msg){ //echo $name . "<br>"; //echo $address . "<br>"; //echo $city . "<br>"; //echo $state . "<br>"; header('Location: process_U2IP.php'); exit(); } } ?> <!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>KulaE_WDP4451_U2IP</title> </head> <body> <div id="content"> <form action="<?php $_SERVER['PHP_SELF']; ?>" method="post"> <h3>Please fill out the form below and upload your resume to apply for a position within our company:</h3> <table> <tr> <td><label for="name"><b>Name*</b></label></td> <td><input name="name" type="text" size="20" id="name" value="<?php echo $name; ?>" /></td> </tr> <tr> <td><label for="address"><b>Address*</b></label></td> <td><input name="address" type="text" size="20" id="address" value="<?php echo $address; ?>" /></td> </tr> <tr> <td><label for="city"><b>City*</b></label></td> <td><input name="city" type="text" size="20" id="city" value="<?php echo $city; ?>" /></td> </tr> <tr> <td><label for="state"><b>State*</b></label></td> <td><input name="state" type="text" size="20" id="state" value="<?php echo $state; ?>" /></td> </tr> <tr> <td><label for="zip"><b>Zip*</b></label></td> <td><input name="zip" type="text" size="20" id="zip" value="<?php echo $zip; ?>" /></td> </tr> <tr> <td><label for="phone"><b>Phone*</b></label></td> <td><input name="phone" type="text" size="20" id="phone" value="<?php echo $phone; ?>" /></td> </tr> <tr> <td><label for="position"><b>Position*</b></label></td> <td><input name="position" type="text" size="20" id="position" value="<?php echo $position; ?>" /></td> </tr> <tr> <td><b>Upload Resume:</b></td> <td><input type="file" name="file" id="file" /> </td> </tr> <tr> <td colspan="2"><p><i>Your information will not be sold or shared with others.</i></p></td> </tr> <tr> <td colspan="2"><p style="color: red;">* denotes required field</p></td> </tr> <tr> <td colspan="2" align="center"><input type="hidden" name="submitted" value="1" /> <input type="submit" value="Submit" /> <input type="reset" name="reset" value="Reset" /></td> </tr> </table> </form> <?php echo $display_errors; ?> </div> </body> </html> <?php session_start(); $name = $_SESSION['name']; $address = $_SESSION['address']; $city = $_SESSION['city']; $state = $_SESSION['state']; $zip = $_SESSION['zip']; $phone = $_SESSION['phone']; $position = $_SESSION['position']; $display_block = " <table> <tr> <td><b>Name:</b></td> <td>$name</td> </tr> <tr> <td><b>Address:</b></td> <td>$address</td> </tr> <tr> <td><b>City:</b></td> <td>$city</td> </tr> <tr> <td><b>State:</b></td> <td>$state</td> </tr> <tr> <td><b>Zip Code:</b></td> <td>$zip</td> </tr> <tr> <td><b>Phone Number:</b></td> <td>$phone</td> </tr> <tr> <td><b>Position Desired:</b></td> <td>$position</td> </tr> </table>"; echo $display_block; ?>
  5. So, I have to use sessions? I thought after it validated, it was submitting to the second page, so I thought I could still use post to get the variables?
  6. I need some help displaying the posted values onto a second page. I thought I was doing it right, but nothing is showing up on my second page. I have my form set to PHP_SELF to validate before sending the user to the second page, and it's working just fine. If no errors are present, the user is redirected to the second page, but it's supposed to be displaying their posted data, but it's not. What am I doing wrong? <?php /*$name = ""; $address = ""; $city = ""; $state = ""; $zip = ""; $phone = ""; $position = ""; $display_errors = "";*/ if (@$_POST['submitted']){ $name = (@$_POST['name']); $address = (@$_POST['address']); $city = (@$_POST['city']); $state = (@$_POST['state']); $zip = (@$_POST['zip']); $phone = (@$_POST['phone']); $position = (@$_POST['position']); if (get_magic_quotes_gpc()){ $name = stripslashes($name); $address = stripslashes($address); $city = stripslashes($city); $state = stripslashes($state); $zip = stripslashes($zip); $phone = stripslashes($phone); $position = stripslashes($position); } $error_msg=array(); if ($name==""){ $error_msg[]="Please enter your name"; } if ($address==""){ $error_msg[]="Please enter your address"; } if ($city==""){ $error_msg[]="Please enter your city"; } if ($state==""){ $error_msg[]="Please enter your state"; } if ($zip==""){ $error_msg[]="Please enter your zip code"; } if ($phone==""){ $error_msg[]="Please enter your phone number"; } if ($position==""){ $error_msg[]="Please enter your desired position"; } if ($error_msg){ $display_errors = "<ul style=color:red>\n"; foreach ($error_msg as $err){ $display_errors .= "<li>".$err."</li>\n"; } $display_errors .= "</ul>\n"; } if (!$error_msg){ //echo $name . "<br>"; //echo $address . "<br>"; //echo $city . "<br>"; //echo $state . "<br>"; header('Location: process_U2IP.php'); exit(); } } ?> <!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>Forms1.php</title> </head> <body> <div id="content"> <form action="<?php $_SERVER['PHP_SELF']; ?>" method="post"> <h3>Please fill out the form below and upload your resume to apply for a position within our company:</h3> <label for="name">Name*</label><br /> <input name="name" type="text" size="20" id="name" value="<?php echo $name; ?>" /><br /> <label for="address">Address*</label><br /> <input name="address" type="text" size="20" id="address" value="<?php echo $address; ?>" /><br /> <label for="city">City*</label><br /> <input name="city" type="text" size="20" id="city" value="<?php echo $city; ?>" /><br /> <label for="state">State*</label><br /> <input name="state" type="text" size="20" id="state" value="<?php echo $state; ?>" /><br /> <label for="zip">Zip*</label><br /> <input name="zip" type="text" size="20" id="zip" value="<?php echo $zip; ?>" /><br /> <label for="phone">Phone*</label><br /> <input name="phone" type="text" size="20" id="phone" value="<?php echo $phone; ?>" /><br /> <label for="position">Position*</label><br /> <input name="position" type="text" size="20" id="position" value="<?php echo $position; ?>" /><br /> <p><i>Your information will not be sold or shared with others.</i></p> <p style="color: red;">* denotes required field</p> <input type="hidden" name="submitted" value="1" /> <input type="submit" value="Submit" /> <input type="reset" name="reset" value="Reset" /> </form> <?php echo $display_errors; ?> </div> </body> </html> <?php $name = (@$_POST['name']); $address = (@$_POST['address']); $city = (@$_POST['city']); $state = (@$_POST['state']); $zip = (@$_POST['zip']); $phone = (@$_POST['phone']); $position = (@$_POST['position']); $display_block = " <table> <tr> <td><b>Name:</b></td> <td>$name</td> </tr> <tr> <td><b>Address:</b></td> <td>$address</td> </tr> <tr> <td><b>City:</b></td> <td>$city</td> </tr> <tr> <td><b>State:</b></td> </tr> </table>"; echo $display_block; ?> It's just displaying the table but with no values or blank values for the posted variables. Can anyone help?
  7. Can anyone help me with adding a link to an uploaded file? What I have is a script that allows the user to upload a file, which saves into a folder on the server named "upload". I want to create a link that allows the user to open that file after it is downloaded. Here is what I have so far, but it's not working right. Can anyone help me out? <?php if ((($_FILES["file"]["type"] == "application/msword") || ($_FILES["file"]["type"] == "application/pdf")) && ($_FILES["file"]["size"] < 20000)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; if (file_exists("upload/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; } } } else { echo "Invalid file. Only MSWord and PDF documents accepted with size under 1024KB."; } ?> <p>View uploaded resume: <a href="upload/<?php $_FILES["file"]["name"]; ?>">here</a></p>
  8. I added: position: absolute; z-index: 2; And that did the trick. Thanks guys!
  9. I'm having some CSS issues. I can't get this logo (KISSArmy) to be positioned the way I want it. Whenever I try to move the main content section up, the logo moves, too. How can I get the main content moved up more and the logo to not move? Here are the two files we're workign with and here's the link to a live version of it: http:webdesignsbyliz.com/kissarmy index.php: <?php defined( '_JEXEC' ) or die( 'Restricted access' ); ?> <?php echo '<?xml version="1.0" encoding="utf-8"?'.'>'; ?> <!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" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" > <head> <jdoc:include type="head" /> <link href="<?php echo $this->baseurl ?>/templates/transparent_bliss_1.5/css/template.css" rel="stylesheet" type="text/css" /> <?php if ($this->params->get('showselector') == "show") { echo "<link href=\"".$this->baseurl."/templates/transparent_bliss_1.5/css/img".$this->params->get('defaultimage').".css\" rel=\"stylesheet\" type=\"text/css\" /> \n"; foreach (range(1, 6) as $bgimage) { if ($this->params->get('defaultimage') != $bgimage) { echo "<link href=\"".$this->baseurl."/templates/transparent_bliss_1.5/css/img".$bgimage.".css\" title=\"img".$bgimage."\" rel=\"alternate stylesheet\" type=\"text/css\" /> \n"; } } include ("imageswapper.php"); } else if ($this->params->get('showselector') == "random" || $this->params->get('showselector') == "modRand") { $randomImage = "img"; $randomImage .= rand(1, 6); echo "<link href=\"".$this->baseurl."/templates/transparent_bliss_1.5/css/".$randomImage.".css\" rel=\"stylesheet\" type=\"text/css\" /> \n"; } else if ($this->params->get('showselector') == "hide" || $this->params->get('showselector') == "module") { echo "<link href=\"".$this->baseurl."/templates/transparent_bliss_1.5/css/img".$this->params->get('defaultimage').".css\" rel=\"stylesheet\" type=\"text/css\" /> \n"; } ?> <!--[if IE 6]> <style type="text/css"> img, div, td { behavior: url(<?php echo $this-> baseurl ?>/templates/transparent_bliss_1.5/js/iepngfix.htc); } </style> <link href="<?php echo $this->baseurl."/templates/transparent_bliss_1.5/css/template-ie6.css";?>" rel="stylesheet" type="text/css" media="all" /> <![endif]--> <body> <div id="wrapper"> <div id="headwrap"> <div id="logo"></div> <div id="topbannerad"><jdoc:include type="modules" name="user5" style="xhtml" /></div> </div> <div id="leftwrap"> <div><img src="<?php echo $this->baseurl ?>/templates/transparent_bliss_1.5/images/left-top.png" alt="top-slice" width="180" height="10" border="0" /></div> <div id="left"> <div id="leftinner2"> <jdoc:include type="modules" name="left" style="xhtml" /> <jdoc:include type="modules" name="user1" style="xhtml" /> </div> </div> <div><img src="<?php echo $this->baseurl ?>/templates/transparent_bliss_1.5/images/left-bottom.png" alt="" width="180" height="10" border="0" /></div> </div> <div id="right"> <div><img src="<?php echo $this->baseurl ?>/templates/transparent_bliss_1.5/images/right-top.png" border="0" alt="" width="600" height="10" border="0" /></div> <div id="rightinner"> <div id="rightinner2"> <?php if ($this->params->get('showselector') == "module" || $this->params->get('showselector') == "modRand") { ?> <div id="TopModule"> <jdoc:include type="modules" name="top" style="xhtml" /> </div> <?php } else if ($this->params->get('showselector') == "show") { ?> <center> <h1 style="text-align: center;">Select background</h1> <br /> <?php echo "<a href=\"javascript:chooseStyle('none', 60)\" checked=\"checked\" /><img src=\"".$this->baseurl."/templates/transparent_bliss_1.5/background_images/thumb".$this->params->get('defaultimage').".jpg\" alt=\"background image ".$this->params->get('defaultimage')."\" border=\"0\" class=\"bgthumbs\" /></a> \n"; foreach (range(1, 6) as $bgimage) { if ($this->params->get('defaultimage') != $bgimage) { echo "<a href=\"javascript:chooseStyle('img".$bgimage."', 60)\" /><img src=\"".$this->baseurl."/templates/transparent_bliss_1.5/background_images/thumb".$bgimage.".jpg\" alt=\"background image ".$bgimage."\" border=\"0\" class=\"bgthumbs\" /></a> \n"; } } ?> </center> <?php } ?> <jdoc:include type="component" /> <div id="BottomModule"> <jdoc:include type="modules" name="user3" style="xhtml" /> </div> </div> </div> <div><img src="<?php echo $this->baseurl ?>/templates/transparent_bliss_1.5/images/right-bottom.png" alt="" width="600" height="10" border="0" /></div> <div id="joomlabear"><center>Copyright 2010 Web Designs By Liz. All rights reserved.</center></div> </div> <div id="farrightwrap"> <div></div> <div id="farright"> <div id="farrightinner2"> <jdoc:include type="modules" name="user4" style="xhtml" /> <jdoc:include type="modules" name="right" style="xhtml" /> </div> </div> <div></div> </div> </div> </div> </body> </html> template.css: html { padding: 0px; margin: 0px; border: 0px; } body { margin: 0px; padding: 0px; border: 0px; height: 100%; width: 100%; text-align: center; /* required for centering the page in IE */ background-repeat: no-repeat; font-family: Arial, sans-serif; font-size: 12px; color: #E9E9E9; line-height: 19px; background-attachment: fixed; background-position: left bottom; background-color: #000000; } .bodytext p { font-size: 12px; } .poll { overflow: hidden; text-align: left; } .bgthumbs { margin: 2px; border: 2px solid #000000; } .bgthumbs a:hover { border: 2px solid #0099CC; } h1, h2, h3, h4, p, ul, li, .poll, table.contentpaneopen { margin: 0px; padding: 0px; border:0px; list-style-type:none; font-size:12px; } h1,h2,h3,.componentheading, .contentheading { font-family: Trebuchet MS, Tahoma, Verdana, Arial; font-style: inherit; padding-bottom: 0px; text-align: left; color: #88CFFF; line-height: 18px; font-size: 16px; } div.componentheading { padding-bottom: 10px; text-decoration: underline; } .moduletable_menu h3 { text-indent: 10px; padding-bottom: 5px; } h1,.componentheading, .contentheading { font-size: 18px; } fieldset.input { border: 0px none; } a:link { color: #88CFFF; font-weight: bold; } a:hover { text-decoration: none; } a:visited{ color: #88CFFF; font-weight: bold; } .moduletable { padding-bottom: 15px; } .mostread { list-style-type: none; } #logo { width: 550px; height: 200px; float: left; background-image: url(../images/logo.png); background-repeat: no-repeat; margin-left: 650px; } #headwrap { width: 980px; height: 90px; margin-bottom: 10px; } #topbannerad { float: right; width: 728px; height: 90px; } #wrapper { height: 100%; width: 980px; margin-right: auto; margin-left: auto; margin-top: 10px; clear: both; } #leftwrap { text-align: left; width: 180px; margin-right: 10px; float: left; clear: both; } * html #left { display: inline; } #left{ width: 180px; background-image: url(../images/left-mid.png); background-repeat: repeat-y; } #leftinner2 .moduletable{ padding-left: 10px; } #right { width: 600px; text-align: left; float: left; } * html #right { display: inline; } #rightinner { background-image: url(../images/right-mid.png); background-repeat: repeat-y; width: 600px; margin: 0px; padding: 0px; border: 0px; } #rightinner2 { margin-left: 0px; list-style-type: none; padding: 20px; border: 0px; } table.contentpane { width: 558px; overflow: hidden; display: inline; padding-bottom: 10px; } #farrightwrap { text-align: left; margin-left: 0px; width: 180px; margin-left: 10px; float: right; } #farright { width: 180px; background-image: url(../images/left-mid.png); background-repeat: repeat-y; } * html #farright { display:inline; } #farrightinner2 { padding-left: 10px; padding-right: 10px; overflow: hidden; } #TopModule { width: 468px; margin-right: auto; margin-left: auto; margin-bottom: 15px; } #BottomModule { width: 468px; margin-right: auto; margin-left: auto; } .logoLeft { float: left; margin: 10px; } .module_menu, #left .module { list-style-type: none; border: 0px; padding: 0px; margin: 0px; } ul.menu { padding-bottom: 15px; border-top-width: 1px; border-top-style: dotted; border-top-color: #666666; } .menu li, .menu { display: block; list-style-type: none; font-family: Arial, Helvetica, sans-serif; text-indent: 18px; line-height: 21px; } .menu li a { display: block; height: 20px; padding: 3px; position: relative; left: 1px; width: 172px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #666666; background-image: url(../images/star.png); background-repeat: no-repeat; background-position: 4px 50%; } .menu li a:link, ul.menu a:visited { display: block; color: #FFF; text-decoration: none; font-weight: bold; } .menu li a:hover { display: block; background-color: #88cfff; color: #000; background-image: url(../images/star-hover.png); background-repeat: no-repeat; background-position: 4px 50%; } ul#mainlevel a:link#active_menu, ul#mainlevel a:visited#active_menu { background-image: none; background-color: #FFF; color: #000; } li.mostread, li.latestnews{ padding-bottom: 4px; } li.mostread, li.latestnews a:link{ background-repeat: no-repeat; } .bear { float: right; } .sublevel { text-indent: 15px; } .column_separator { padding-left: 20px; } .article_column { } li.contentpaneopen, ul.contentpaneopen { list-style-type: none; } table .contentpaneopen { width: 100%; display: inline; } .buttonheading img, .hasTip img, .bs_contentdiv img { border: 0px; } .small, .createdate, .modifydate { font-size: 90%; font-style: italic; padding-bottom: 5px; } a.readon { font-size: 12px; float: right; margin-top: 2px; padding-top: 3px; padding-right: 20px; padding-bottom: 3px; padding-left: 7px; display: inline; background-color: #000000; background-image: url(../images/arrow.png); background-repeat: no-repeat; background-attachment: scroll; C40004-height: 15px; color: #88cfff; font-weight: bold; text-decoration: none; text-transform: uppercase; border: 1px solid #666; background-position: right 48%; } a.readon:hover, a.readon:active, a.readon:focus { color:#000000; background-color: #88cfff; background-image: url(../images/arrow-hover.png); background-repeat: no-repeat; background-attachment: scroll; background-x-position: 5px; background-y-position: 48%; border: 1px solid #000000; } html { margin-bottom: 1px; height: 100%!important; height: auto; } #mod_search_searchword { font-size: 12px !Important; width: 140px; } #mod_login_password, #mod_login_username { width:160px; color: #FFF; } form { margin: 0; padding: 0; } input, select { font-size: 12px !Important; } label { font-size: 12px; text-align: left; margin: 0px; padding: 0px; } .pollstableborder { text-align: left; } select, .inputbox { padding: 4px; font-size: 12px; } textarea { font-size: 12px; } .button { border: 1px solid #666; padding: 2px 6px!important; background: url(../images/button-bg.gif) repeat-x top #000; color: #88CFFF; font-weight: bold; font-size: 12px; } #modlgn_remember { border: 0px; padding: 0px; margin: 0px; height: 14px; width: 14px; } #form-login { } ul.latestnews { } .button:hover { background: url(../images/button-bg.gif) repeat-x top #88CFFF; color: #000; border: 1px solid #000; } .button:active, .button:focus { border: 1px solid #222222; } #form-login-remember { display:inline; vertical-align:top; } #mod_search_searchword .inputbox { font-size:12px; } .inputbox { font-size: 12px; border: 1px solid #3F3F3F; background: #000; color: #FFFFFF; text-indent: 3px; } #left .inputbox, #mainContent .inputbox { margin-top: 5px; margin-bottom: 5px; background: #000 !important; text-indent: 3px; } #left .inputbox:hover, #left .inputbox:focus, #mainContent .inputbox:hover, #mainContent .inputbox:focus, #farrightinner2 .inputbox:focus, #farrightinner2 .inputbox:hover{ border: 1px solid #88CFFF; } #farrightinner2 form { width:160px; } #form-login-remember .inputbox:hover { border:none } Can anyone help, please??
  10. Okay, here's the problem I have. I have an image that uses JQuery to display another image upon mouseenter, and then the image disappears after mouseleave. The problem I have, is on that second image that displays, I have some text, and I would like to have that text be turned into "clickable" text, which in turn would function as a normal hyperlink that would load a page into the main div area when the user clicks the text. Here is a screen shot of the navigation before and after the mouseenter and mouseleave happens: normal: after mouseenter: Is there a way to make each of those lines of text become like hyperlinks? Could maybe an image map be used?
  11. I changed the section for the select list to this: class = document.getElementById("class").value; if (class == "0") { document.getElementById("classError").style.display = "inline"; document.getElementById("class").select(); document.getElementById("class").focus(); return false; } and it does in fact display the error, although it still submits. Can anyone help?
  12. I'm having some trouble with my validation script. I'm still pretty new to validation and JavaScript, so please bare with me. I have a simple form: <form method="post" action="create.php"name="create" onSubmit="return checkForm();"> <table> <tr> <td>Name:</td> <td><input type="text" id="name" name="name"/></td> <td><div class=error id=nameError>* Please enter a character name.</div></td> </tr> <tr> <td>Class:</td> <td> <select name="class" id="class"> <option id="choose" value="choose" selected="selected">Choose Class</option> <option id="fighter" value="fighter">Fighter</option> <option id="cleric" value="cleric">Cleric</option> <option id="mage" value="mage">Mage</option> <option id="sorcerer" value="sorcerer">Sorcerer</option> <option id="barbarian" value="barbarian">Barbarian</option> <option id="priest" value="priest">Priest</option> </select> </td> <div class=error id=classError>* Please choose a character class.</div></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"> <input type="submit" value="Create Character" id="submit" /> <input type="reset" value="Reset" id="reset" /> </td> </tr> </table> </form> And my textbox validation works, but I can't get my select option list to validate: function checkForm() { name = document.getElementById("name").value; if (name == "") { document.getElementById("nameError").style.display = "inline"; document.getElementById("name").select(); document.getElementById("name").focus(); return false; } //return true; //} if (class.selectedIndex == 0) { document.getElementById("classError").style.display = "inline"; return false; } return true; } What am I doing wrong? Can anyone help?
  13. I have a php-based chat room that I found online, but I would like some help on improving it. I know there is a way to stop the flickering when the page refreshes using JavaScript or something I think, but I am unsure of how to do it. I will assume this topic might need to go into the JavaScript section, but I wasn't exactly sure if someone in PHP might be able to help, so I first posted it here. But move it if it needs to me moved i guess mods. I found a chat room that does it called jenChat, but I do not know how to incorporate this into this chat room. What I want to do is stop the flickering when the chat screen refreshes and also not have the screen automatically scroll back up, which would allow users to scroll up and read previous comments, then scroll back down when they are done. Right now if they try that, in a second it scrolls back down, so they wold be unable to read any previous comments in the chat. Here is what I have so far. The main page you view: chatframe: <?php print "<iframe src='chatlog.php' name='chatlogframe' width='350' height='400'></iframe>"; print "<br><br>"; print "<iframe src='submit.php' width='380' height='180' frameborder='0'scrolling='no'></iframe><br><br>"; ?> The page that shows the chat messages: chatlog.php: <?php include "connect.php"; $getnummessages="SELECT COUNT(*) as messagecount from chatmessages"; $getnummessages2=mysql_query($getnummessages) or die("blah"); $getnummessages3= mysql_result($getnummessages2, 0); if($getnummessages3>21) { // $startrow=$getnummessages3-20; $startrow=1; } else { $startrow=1; } $getmsg="SELECT name, message from chatmessages order by postime ASC limit $startrow,$getnummessages3"; $getmsg2=mysql_query($getmsg) or die(mysql_error()); while($getmsg3=mysql_fetch_array($getmsg2)) { $message = $getmsg3['message']; $message=Smiley($message); //Smiley faces print "<font color='red'><b>$getmsg3[name]:</b></font> $getmsg3[message]<br>"; } function Smiley($texttoreplace) { $smilies=array( '' => "<img src='images/smile.gif'>", ':blush' =>"<img src='images/blush.gif'>", ':angry' =>"<img src='images/angry.gif'>", ''=> "<img src='images/shocked.gif'>", 'fuck'=>"$#$%", 'Fuck'=>"&$#@" ); $texttoreplace=str_replace(array_keys($smilies), array_values($smilies), $texttoreplace); return $texttoreplace; } ?> <script> setTimeout("window.location.replace('chatlog.php')",2000); </script> And here is the jenChat example that shows how to stop the flickering and to the scrolling problem: chat.php: <?php session_start(); if(!$_SESSION['jenChat_UserID']){ header("Location: ./login.php"); exit; } else if(date("YmdHis",time() - 5) > $_SESSION['jenChat_Prevtime']){ header("Location: ./login.php?logout=true"); exit; } ?><!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" lang="en-US" xml:lang="en-US"> <head> <title>jenChat</title> <style type="text/css"> #chatContents{height:300px; width:200px;} init.php: <?php session_start(); /* * replace the parameters used here with the appropriate information * for your system. */ $dbhandle = mysql_connect("server","user","password"); mysql_select_db("database_name"); /* * IMPORTANT: magic quotes are bad. Ideally, you should turn them off * in your php.ini, but if you are unable to, the code below will fix * the $_POST array for you. * * See http://www.php.net/manual/en/security.magicquotes.php * * If you aren't using prepared statements (mysqli, Pear:DB) or manually * escaping every variable that goes into a query, you are asking to get * pwned. For maximum portability, jenChat uses mysql_real_escape_string, * but prepared statements are generally the way to go. * * If you didn't understand that last paragraph (or even if you * did), read up on SQL Injection and why you need to worry about it. * * http://www.unixwiz.net/techtips/sql-injection.html * * OK, carry on */ if(get_magic_quotes_gpc()){ $_POST = array_map('stripslash', $_POST); } function stripslash($value){ if(is_array($value)) return array_map('stripslash', $value); else return stripslashes($value); post.php: <?php require_once('init.php'); /* make sure the person is logged in. */ if(!isset($_SESSION['jenChat_UserID'])) exit; /* make sure something was actually posted. */ if(sizeof($_POST)){ $expiretime = date("YmdHis",time() - 30); /* delete expired messages. */ mysql_query("DELETE FROM jenChat_Messages WHERE Posted <= '" . $expiretime . "'"); /* delete inactive participants. */ mysql_query("DELETE FROM jenChat_Users WHERE LastUpdate <= '" . $expiretime. "'"); /* post the message. */ mysql_query("INSERT INTO jenChat_Messages (UserID,Posted,Message) VALUES( " . $_SESSION['jenChat_UserID'] . ", '" . date("YmdHis", time()) . "', '" . mysql_real_escape_string(strip_tags($_POST['message'])) . "' )"); header("Location: post.php"); exit; <!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" lang="en-US" xml:lang="en-US"> <head> <script type="text/javascript"><!-- if(parent.resetForm) parent.resetForm(); //--> </script> </head> </html> thread.php: <?php require_once('init.php'); /* make sure the person is logged in. */ if(!isset($_SESSION['jenChat_UserID'])) exit; $currtime = date("YmdHis",time()); /* maintains this user's state as active. */ mysql_query("UPDATE jenChat_Users SET LastUpdate = '" . $currtime . "' WHERE UserID = " . $_SESSION['jenChat_UserID']); /* grab any messages posted since the last time we checked. Notice we say >= and <. This is to guarantee that we don't miss any messages that are posted at the same instant this query is executed.*/ $sql = "SELECT Message,UserName FROM jenChat_Messages INNER JOIN " . "jenChat_Users ON jenChat_Messages.UserID = jenChat_Users.UserID WHERE Posted >= '" . $_SESSION['jenChat_Prevtime'] . "' AND Posted < '" . $currtime . "' ORDER BY Posted"; $res = mysql_query($sql); ?> <!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" lang="en-US" xml:lang="en-US"> <head></head> <body> <? if(mysql_num_rows($res)){ echo '<div id="contents">'; while($row = mysql_fetch_array($res)){ echo '<div><strong>' . htmlspecialchars($row['UserName']) . ': </strong>' . htmlspecialchars($row['Message']) . '</div>'; } echo '</div>'; } $_SESSION['jenChat_Prevtime'] = $currtime; ?> </body> </html>[pre] } ?>[/pre][pre] } ?>[/pre][pre] </style> </head> <body> <h1>jenChat</h1> <a href="login.php?logout=true">Logout</a><br /> <iframe id="chatContents" name="chatContents" src="contents.html"></iframe> <form target="post" method="post" action="post.php"> <input type="text" name="message" id="message" style="width: 250px" /> <input type="submit" value="Send" class="submit" /> </form> <iframe id="post" name="post" src="post.php" style="width: 0px; height: 0px; border: 0px;"></iframe> <iframe id="thread" name="thread" src="thread.php" style="width: 0px; height: 0px; border: 0px;"></iframe> </body> </html>[/pre] This was the Javascript in the jenChat that is in the post.php page that is supposed to stop the flickering: [pre]<!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" lang="en-US" xml:lang="en-US"> <head> <script type="text/javascript"><!-- if(parent.resetForm) parent.resetForm(); //--> </script> </head> </html>[/pre] This is the Javscript that is sppsoed to refresh the page and is supposed to go into thread.php: [pre]<script type="text/javascript"><!-- if(parent.insertMessages && document.getElementById("contents")) parent.insertMessages(document.getElementById("contents").innerHTML); setTimeout("getMessages()",1000); //poll server again in one second function getMessages(){ document.location.reload(); } //--> </script>[/pre] And this last part goes into chat.php: [pre]<script type="text/javascript"><!-- var cDocument; var cWindow; window.onload = chat_init; function chat_init(){ var chatContents = document.getElementById("chatContents"); //set up a reference to the window object of the IFRAME if(window.frames && window.frames["chatContents"]) //IE5, Konq, Safari cWindow = window.frames["chatContents"]; else if(chatContents.contentWindow) //IE5.5+, Moz 1.0+, Opera cWindow = chatContents.contentWindow; else //Moz < 0.9 (Netscape 6.0) cWindow = chatContents; //set up a reference to the document object of the IFRAME if(cWindow.document) //Moz 0.9+, Konq, Safari, IE, Opera cDocument = cWindow.document; else //Moz < 0.9 (Netscape 6.0) cDocument = cWindow.contentDocument; } function insertMessages(content){ //place the new messages in a div var newDiv = cDocument.createElement("DIV"); newDiv.innerHTML = content; //append the messages to the contents cDocument.getElementById("contents").appendChild(newDiv); //scroll the chatContents area to the bottom cWindow.scrollTo(0,cDocument.getElementById("contents").offsetHeight); } function resetForm(){ document.getElementById("message").value = ""; document.getElementById("message").focus(); }//--> </script>[/pre] Here is the link to the jenChat tutorial: http://code.jenseng.com/jenChat/ . Please if anyone can help me with these two problems. I had trouble getting my messages to post and view correctly with jenChat, which is why I'm not using it. But, the one I'm using has no problems with that. i just need to stop the flicking and scrolling issue so that people can view the previous messages while new ones are begin posted and while the page refreshes. Can anyone help?
  14. I have this php chat room I found online, and I was trying to make a few additions, but I am running into some trouble. When the user clicks a smiley face button, I want the smiley face icon image to display in the chat instead of just the text, like shows up now, but i want the image to show up. Can anyone help me with that? Also I am receiving this error when a chat message finally shows up in the chat: Notice: Undefined variable: message in C:\wamp\www\chatlog.php on line 35 Here is the main page that shows the chat: chatframe: <?php print "<iframe src='chatlog.php' name='chatlogframe' width='350' height='400'></iframe>"; print "<br><br>"; print "<iframe src='submit.php' width='380' height='180' frameborder='0'scrolling='no'></iframe><br><br>"; ?> Here is the submit page: submit.php: <?php include "connect.php"; if(isset($_POST['submit'])) //if submit button push has been detected { $message=$_POST['message']; $name=$_POST['name']; if(strlen($message)<1) { print "You did not input a message"; } else if(strlen($name)<1) { print "You did not enter a name, please try again."; } else { $message=strip_tags($message); $IP=$_SERVER["REMOTE_ADDR"]; //grabs poster's IP $checkforbanned="SELECT ip from ipbans where ip='$IP'"; $checkforbanned2=mysql_query($checkforbanned) or die("Could not check for banned IPS"); if(mysql_num_rows($checkforbanned2)>0) //IP is in the banned list { print "You IP is banned from posting."; } else { $thedate = date("U"); //grab date and time of the post $insertmessage="INSERT into chatmessages (name,ip,postime,message) values('$name','$IP','$thedate','$message')"; mysql_query($insertmessage) or die("Could not insert message"); } } } print "<form action='submit.php' method='post' name='form'>"; print "Your name:<br>"; print "<input type='text' name='name' size='20'><br>"; print "Your message:<br>"; print "<textarea name='message' cols='40' rows='2'></textarea><br>"; print "<a onClick=\"addSmiley('')\"><img src='images/smile.gif'></a> "; //replace images/smile.gif with the relative path of your smiley print "<a onClick=\"addSmiley('')\"><img src='images/sad.gif'></a> "; print "<a onClick=\"addSmiley('')\"><img src='images/wink.gif'></a> "; print "<input type='submit' name='submit' value='submit'></form>"; print "<script language=\"Java Script\" type=\"text/javascript\">\n"; print "function addSmiley(textToAdd)\n"; print "{\n"; print "document.form.message.value += textToAdd;"; print "document.form.message.focus();\n"; print "}\n"; print "</script>\n"; print "<br><br>"; ?> And here is the chatlog page: chatlog.php: <?php include "connect.php"; $getnummessages="SELECT COUNT(*) as messagecount from chatmessages"; $getnummessages2=mysql_query($getnummessages) or die("blah"); $getnummessages3= mysql_result($getnummessages2, 0); if($getnummessages3>21) { $startrow=$getmessages3-20; } else { $startrow=1; } $getmsg="SELECT name, message from chatmessages order by postime ASC limit $startrow,$getnummessages3"; $getmsg2=mysql_query($getmsg) or die(mysql_error()); while($getmsg3=mysql_fetch_array($getmsg2)) { $message=Smiley($message); //Smiley faces print "<font color='red'><b>$getmsg3[name]:</b></font> $getmsg3[message]<br>"; } function Smiley($texttoreplace) { $smilies=array( '' => "<img src='images/smile.gif'>", ':blush' =>"<img src='images/blush.gif'>", ':angry' =>"<img src='images/angry.gif'>", ''=> "<img src='images/shocked.gif'>", 'fuck'=>"$#$%", 'Fuck'=>"&$#@" ); $texttoreplace=str_replace(array_keys($smilies), array_values($smilies), $texttoreplace); return $texttoreplace; } ?> <script> setTimeout("window.location.replace('chatlog.php')",2000); </script> I see it's using a function to display the smileys, but I can't figure out how to make them the images instead of the text. Can anyone help?
  15. Thank you, ignace. You are always very helpful and your suggestions are always appreciated :-)
  16. I guess since I was already echoing the form before this header was told to be run, I was getting a header error. I used this instead: echo '<META HTTP-EQUIV="Refresh" Content="0; URL=success.php">'; And I have solved my problem, for now. I will later add validation to get around this problem. Sorry for all the confusion. I was using a tutorial book and it's kind of old, so apparently this used to work! Thanks for all the help guys!
  17. I have the following script for allowing users to sign up for a newsletter. When the user leaves the textbox blank, it's supposed to redirect them back to the same page, but instead it is displaying a blank page. Can anyone help me with why? <?php //set up a couple of functions function doDB() { global $conn; //connect to server and select database; you may need it $conn = mysql_connect("localhost", "root", "root") or die(mysql_error()); mysql_select_db("smrpg",$conn) or die(mysql_error()); } function emailChecker($email) { global $conn, $check_result; //checl that e-mail is not already in list $check = "select id from subscribers where email = '$email'"; $check_result = mysql_query($check,$conn) or die(mysql_error()); } //determine if they need to see the form or not if ($_POST['op'] !="ds") { //they do, so create form block $display_block = " <form method=POST action=\"$_SERVER[php_SELF]\"> <p><strong>Your E-Mail Address:</strong><br> <input type=text name=\"email\" size=40 maxlength=150></p> <p><strong>Action:</strong><br> <input type=radio name=\"action\" value=\"sub\" checked> subscribe <input type=radio name=\"action\" value=\"unsub\"> unsubscribe <input type=\"hidden\" name=\"op\" value=\"ds\"></p> <p><input type=submit name=\"submit\" value=\"Submit Form\"></p> </form>"; } else if (($_POST['op'] == "ds") && ($_POST['action'] == "sub")) { //trying to subscribe; validate email address if ($_POST['email'] == "") { header("Location: newsletter.php"); exit; } //connect to database doDB(); //check that email is in list emailChecker($_POST['email']); //get number of results and do action if (mysql_num_rows($check_result) < 1) { //add record $sql = "insert into subscribers values('', '$_POST[email]')"; $result = mysql_query($sql,$conn) or die(mysql_error()); $display_block = "<p>Thanks for signing up!</p>"; } else { //print failure message $display_block = "<p>You're already subscribed!</p>"; } } else if (($_POST['op'] == "ds") && ($_POST['action'] == "unsub")) { //trying to unsubscribe; validate email address if ($_POST['email'] == "") { header("Location: newsletter.php"); exit; } //connect to database doDB(); //check that email is in list emailChecker($_POST['email']); //get number of results and do action if (mysql_num_rows($check_result) < 1) { //print failure message $display_block = "<p>Couldn't find your address!</p> <p>No action was taken.</p>"; } else { //unsubscribe the address $id = mysql_result($check_result, 0, "id"); $sql = "delete from subscribers where id = '$id'"; $result = mysql_query($sql,$conn) or die(mysql_error()); $display_block = "<p>You're unsubscribed!</p>"; } } ?> The rest of the code works fine; the user can subscribe, unsubscribe, and be notified if they already have subscribed.
  18. Andy-H: The code you suggested just outputs a blank page when I navigate to the login page, so I cannot test it. PFMaBiSmAd: I'm not sure if I have my error reporting on. Can you tell me how to check and turn it on? I'm using MAMP, so I'll have to look for the php.ini page. I'm not sure what it was set to as its default.
  19. I have included the session_start() on the login page, but the logged in status doesn't show when the user logs in and doesn't change when they log out. What happens is when the user logs in, it displays this part of the code: die('<a href="'.$user_area_location.'"> Go to your user account</a> or go back to <a href=choose_character.php>choose_character.php</a>'); Then the logged in status does not update until the user navigates to another page. Also, when the user logs out, it doesn't show the updated logged in status, as it stays on the login page, and just tells them they have logged out, but when they navigate to another page, they are shown to be logged out. Any help?
  20. The problem I'm having now is that the header redirect isn't working and my logout isn't working right. When I login, it stays on the log in page instead of redirecting, and when I log out, it stays on the login page as well. Any help?
  21. Yes, it outputs account.php when I echo the $user_area_location, and i added the session start to the include that connects to my database which is included in my template page. That should include it in each page shouldn't it? Oh, I tried adding the session start to the individual login page and now the logged in status shows. I guess I do have to put it on each page instead of just including it in template. But still, my page redirect isn't working. Any suggestions why?
  22. You are right. When I log in, it will display the logged in status if I echo it as well as the user location. But why won't it show the logged in status where I have it set? I am using a template, and I have the logged in status showing by including the php page. Here is the php page I have that is supposed to display it, maybe you can help with it then: <div id="log"> <?php if (isset($_SESSION['loggedIn']) == 1) { ?> <p>Welcome, <?php echo $_SESSION['userName'] ?> (<a href="login.php?action=logoff" title="Log Out">Log Out</a>)</p> <?php } else { ?> <p>Please <a href="login.php">log in</a></p> <?php } ?> <> Plus, it's still not redirecting to the user page for whatever reason :-(
  23. :-( Nope, same thing. I must have something set up wrong, I'm just not sure what. My register page works fine, it's just the log in and logge din status that isn't working for some reason. >.<
  24. Now it is simply taking the error message out and staying or redirecting back to the login page, but with no input boxes to log in with, but also with no logged in status set. I can't understand what I am doing wrong. :-(
  25. I have the following log in script, but for some reason it's not setting the logged in state to logged in. Can anyone help with why? <?php $user_area_location = 'account.php'; // Location of the user area # # $error = array(); if(isset($_GET['action'])) { switch($_GET['action']) { case 'logoff': unset($_SESSION['loggedIn']); array_push($error, 'You were logged off.'); break; } } if(!$error) { if(empty($_POST['username'])) { array_push($error, 'You didn\'t supply a username'); } if(empty($_POST['password'])) { array_push($error, 'You didn\'t supply a password'); } } if(!$error){ $result = @mysql_query('SELECT username, email, name FROM `users` WHERE username = \''.mysql_real_escape_string($_POST['username']).'\' AND password = \''.mysql_real_escape_string(md5($_POST['password'])).'\''); if($row = @mysql_fetch_array($result)) { $_SESSION['loggedIn'] = true; $_SESSION['userName'] = $row['username']; $_SESSION['userMail'] = $row['email']; $_SESSION['name'] = $row['name']; header('Location: '.$user_area_location); die('<a href="'.$user_area_location.'"> Go to your user account</a> or go back to <a href=choose_character.php>choose_character.php</a>'); }else{ array_push($error, 'The username or password you provided were not correct'); } } ?> <table cellspacing="2" cellpadding="0" border="0"> <form method="post" action="login.php"> <tr> <td>Username:</td> <td><input type="text" name="username" /></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="password" /></td> </tr> <tr> <td> </td> <td><input type="submit" name="submit" value="Login!" /> <a href="forgot.php">I forgot my username or password</a></td> </tr> </form> </table> <?php if(isset($error) && $error) { ?> <div id="error2"> <ul><?php foreach($error as $key => $value) echo '<li>'.$value.'</li>'; ?></ul> <><?php } ?> I have included the form that is supposed to log the user in as well. Can anyone help me figure out why it's not logging the user in? Every time I try to log in, it just says the username and password were incorrect.
×
×
  • 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.