PHP - User Form Failing Miserably...involves Basic Math
Basically this is a pretty straight forward application. The values are all best on a set of conditional statements held in a function and when the user presses submit, it SHOULD calculate the form....However, this is not the case, for some reason it keeps returning 0. I have tried and tried and tried....to no avail. I have attached the files so you can sort through a little easier as there are a good amount of lines. Thanks! [attachment deleted by admin] Similar TutorialsGood evening! <?php include "C:/php-login/ASEngine/AS.php";
if (! app('login')->isLoggedIn()) {
This php code is in a file called test.php and is on my drive Letter O in a sub directory called my old photos . I'm having a problems referencing the include back to the the path of where ASEngine/As.php which is on c drive . I have tried all different relative and absolute paths . Any help would be appreciated Thank You Another bizzare thing that stopped working all of a sudden... I have a registration form and this code no longer works... // Check for First Name. // Allow letters, space, period, apostrophe, and hyphen. if (preg_match('/^[A-Z\'.-]{2-20}$/i', $_POST['first_name'])){ $fn = mysqli_real_escape_string($dbc, $_POST['first_name']); } else { // Add error-message to array. $reg_errors['first_name'] = 'Please enter your first name!'; } All day when I typed in a two letter answer - to speed up typing and testing - things worked fine, but now I get a built-in error message off to the side of the input box. I typed 'ee' and that always worked before but no luck now. The Reg Ex hasn't changed. Could it be that there is a database connectivity issue that is screwing up my RegEx?? If I comment out all of the RegEx stuff then it works and my INSERT works - thanks to AlexWD TomTees Basically, I'm still trying to wrap my head around OOP. What I'm trying to do here is a simple OOP user login script. But when I submit the form, all that happens is that the text fields reset them selves and nothing that I feel should be happening, happens. ie: I submit login data, and either it displays an error or reirects to index page. Neither happen, the form merely resets. Where am I going wrong? Code: [Select] <form name="loginform" id="loginform" action="<?php $_SERVER['PHP_SELF']; ?>" method="post"> <p> <label>Username<br> <input name="user" id="user_login" class="input" size="20" tabindex="10" type="text" /> </label> </p> <p> <label>Password<br> <input name="pass" id="user_pass" class="input" value="" size="20" tabindex="20" type="password"></label> </p> <p class="forgetmenot"><label><input name="rememberme" id="rememberme" value="forever" tabindex="90" type="checkbox"> Remember Me</label></p> <p class="submit"> <input name="login" id="submit" class="button-primary" value="Log In" tabindex="100" type="submit"> <input name="redirect_to" value="/users.php" type="hidden"> </p> </form> Code: [Select] <?php if(isset($_POST['login'])) { $username = $_POST['user']; $password = $_POST['pass']; include("./classes/class.users.php"); USERS::login($username, $password); } ?> Code: [Select] <?php // Yes, my DATABAASE::DoIT(1) // (0) is working as intended (from a different include file) class USERS { var $user; var $pass; var $email; ////////////////////////////////////////////////////////////////////////////////////////////// function login($user, $pass) { include("/var/www/config.php"); DATABASE::DoIt('1'); $hashword = sha1($CONFIG['salt1']."$pass".$CONFIG['salt2']); $sql = "SElECT * FROM users WHERE username='$user' AND hashword='$hashword'"; $result = mysql_query($sql); $count = mysql_num_rows($result); if($count==1) { while ($row = mysql_fetch_assoc($result)) { define('USERS_AUTHENTICATED', true); $_SESSION['USERS_username'] = $row['username']; $_SESSION['USERS_userid'] = $row['userid']; DATABASE::DoIt('0'); header("Location: index.php"); } } else { $_SESSION['loginError'] = true; DATABASE::DoIt('0'); return $_SESSION['loginError']; } DATABASE::DoIt('0'); } } ?> Hello Everyone, I'm a newbie trying to improve my script below. The script works fine but I would like to add the 3 radio buttons computations enhancements Ergo, if a user chooses 'Matte Paper" a 10% would be added to the Price Quote result. If a user chooses ' Gloss Paper, a 10% would be added to the Price Quote result. If a user chooses 'Canvas" , a 20 % would be added to the Price Quote result. If someone could assist with the math or post me a helpful link it would be greatly appreciated. Thank you. Paul from Melbourne, Australia. <div style="border:dashed 1px; width:570px;"> <form method="post" action="<?php echo $_SERVER['php_SELF'];?>"> <p> 1. Enter the size (100w.x180h. cm) you want your picture printed: Width <input type="text" name="width" size="1" maxlength="3" value="0" onFocus="this.value=''; this.style.color='#ff0000';"> Height <input type="text" name="height" size="1" value="0" maxlength="3" value="0" onFocus="this.value=''; this.style.color='#ff0000';"> </p> <p> 2. Choose the printing material for your pictu <input type="radio" value="cms in Matte paper" name="material" size="3" maxlength="3" /> Matte Paper <input type="radio" value="cms in Gloss Paper:" name="material" size="3" maxlength="3" /> Gloss Paper <input type="radio" value="cms in Canvas:" name="material" size="3" maxlength="3" /> Canvas </p> <p> 3. Submit your info for our Price Quote below : <input type="submit" name="submit" value="Submit" /> or: <input type="submit" name="clear" value="Reset" /> </p> <p> 5. Our Price Quote to print your artwork sized: <?php $width = $_POST['width']; /* if artwork wider than 101 cm no quote, exits*/ if ($width >=101) {echo "Error!"; exit ;} $height = $_POST['height']; /* if artwork higher than 181 cm no quote, script exits */ if ($height >=181) {echo "Error!"; exit ;} $measurement = $_POST['measurement']; $material = $_POST['material']; $result = $width * $height; echo " $width x $height $material is: "; echo "$".number_format($result,2). "" ; ?> </p> </form> </div> Hi, im trying to have a math captcha in my registration form, but having trouble with setting it up in my form. sorry for the large code. If i change the value of $_POST['Submit'] to something else like $_POST['Submit1'] and then same for the math image captcha then it works, but i would like it to work as part of the form, makes sense? lol right now the form just posts the value and doesnt check for captcha values! if someone could help me out here that would be great! thank you. Code: [Select] <?php if(isset($_POST['Submit'])){ if($_POST['Submit'] != $_SESSION['security_number']) { $error = ""; } else { $error = ""; } //NEED TO CHECK IF FIELDS ARE FILLED IN if( empty($_POST['name']) && (empty($_POST['email']))){ header("Location:Messages.php?msg=3"); exit(); } if( empty($_POST['pw1']) && (empty($_POST['pw2']))){ header( "Location:Messages.php?msg=4" ); exit(); } $name=$_POST['name']; $email=$_POST['email']; $pw1=$_POST['pw1']; $pw2=$_POST['pw2']; if("$pw1" !== "$pw2" ){ header( "Location:Messages.php?msg=5" ); exit(); } $ip = $_SERVER['REMOTE_ADDR']; //connect to the db server , check if uname exist include('config.php'); $query1=("Select * from user where email='$email'"); $result1= mysql_query($query1); $num1=mysql_num_rows($result1); if ($num1 > 0) {//Email already been used header( "Location:Messages.php?msg=11" ); exit(); }else{ $query=("Select * from user where uname='$name'"); $result= mysql_query($query); $num=mysql_num_rows($result); if ($num > 0) {//Username already exist header( "Location:Messages.php?msg=6" ); exit(); }else{ //if username does not exist insert user details $query=( "INSERT INTO user (uname, pw,email,date_joined,ip,level) VALUES ('$name',md5('$pw1'),'$email',NOW(),'$ip','Normal')"); if (@mysql_query ($query)) { header("location:login.php?reg=1"); exit; } } } mysql_close(); } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html><!-- InstanceBegin template="/Templates/Auth.dwt.php" codeOutsideHTMLIsLocked="false" --> <head> <!-- InstanceBeginEditable name="doctitle" --> <title>Registration</title> <!-- InstanceEndEditable --> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <!-- InstanceBeginEditable name="head" --> <!-- InstanceEndEditable --> <link href="styleLog.css" rel="stylesheet" type="text/css"> <script language="javascript" type="text/javascript"> function reloadCaptcha() { document.getElementById('captcha').src = document.getElementById('captcha').src+ '?' +new Date(); } </script> </head> <body> <table width="100%" border="0" cellspacing="7" cellpadding="0"> <tr class="temptitle"> <td><!-- InstanceBeginEditable name="EditRegion4" -->New User Registration <!-- InstanceEndEditable --></td> </tr> <tr> <td><!-- InstanceBeginEditable name="EditRegion3" --> <form name="form1" action="register.php" method="post"> <table width="657" border="0"> <tr> <td width="122"><div align="left">Name</div></td> <td width="525"><input name="name" type="text" size="40"></td> </tr> <tr> <td><div align="left">Email</div></td> <td><input name="email" type="text" size="40"></td> </tr> <tr> <td><div align="left">Password</div></td> <td><input name="pw1" type="password" size="40"></td> </tr> <tr> <td ><div align="left">Confirm Password </div></td> <td><input name="pw2" type="password" size="40"></td> </tr> <tr> <td><img src="math_captcha/image.php" alt="Click to reload image" title="Click to reload image" id="captcha" onclick="javascript:reloadCaptcha()" /></td> <td><input type="text" name="Submit" value="what's the result?" onclick="this.value=''" /></td> <td> </tr> <tr> <td></td> <td> <input name="Submit" type="submit" value="Register"></td> </tr> </table> </form> <?=$error?> MOD EDIT: code tags added. I'm trying to do a basic form with php which asks for first, last name, and age with validation. I'm having trouble with my validation and the error counter. I want it to redisplay the form with the errors and entered input. My formhandler.php is he Code: [Select] <!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>Form Handler</title> </head> <body> <?php $fName = validateInput($_POST['fName']); $lName = validateInput($_POST['lName']); $age = validateAge($_POST['age']); function displayRequired($fieldName){ echo "The field \"$fieldName\" is required.<br />n"; } function validateInput($fName, $lName){ if ($errorCountInput>0){ echo "Please re-enter the information below.<br />\n"; redisplayForm($firstName, $lastName); } else{ if(empty($fName, $lName)){ displayRequired($fieldName); ++$errorCount; $returnval = ""; } else{ $returnval = trim($fName,$lName); $returnval = stripslashes($returnval); } return($returnval); } } $erorrCount= 0; function validateAge($age){ global $errorCount; if ($errorCount>0){ echo "Please re-enter the information below.<br />\n"; redisplayForm($age); } else{ if(empty($age)){ echo "<p>The age field is required!</p>\n"; ++$errorCount; $returnval = ""; redisplayForm($fName, $lName, $age); } else{ $age = trim($age); $age = stripslashes($age); if(is_numeric($age)){ $age = round($age); if(($age >= 1) && ($age <= 130)){ $agereturnval = $age; } else { echo "<p>The age field must be between 1 and 130.</p>\n"; ++$errorCount; $agereturnval = ""; } }else { echo "<p>The age field must be a number between 1 and 130.</p>\n"; ++$errorCount; $returnval = ""; } } return($returnval); } $errorcount = 0; echo "Hi ".$fName." ".$lName."."."<br />"; echo "You are ".$age." years old. <br />"; echo $_SERVER['SCRIPT_FILENAME']; ?> </body> </html> Any help would be much appreciated. I've looked at this for hours and I just need another set of eyes to pick some things out. Once you get too close to code it gets hard to figure it out. I have a form-to-email that I am trying to use. I'm testing, but I am not getting the orders that I send. Everything else I send to that email I get fine, so something definately wrong with my code somewhere. Thought I was ok (as a beginner) with PHP, but now my ego is taking a beating It is contained all on 1 page - the below coding is the entire page: Code: [Select] <?php if(isset($_POST['t1'])){ // **** CHANGE EMAIL, AFFILIATE ID & AFFILIATE LINK! **** $mymail = 'rjmatthews15@cfl.rr.com'; $cc = 'Website installation (plus124)'; $BoDy = ' '; $FrOm = "From: $_POST[t2]"; $FrOm .= "\r\nReply-To: $_POST[t2]"; $FrOm .= "\r\nX-MAILER: PHP".phpversion(); //Body sends all the sign up info to the $mymail address $BoDy .= 'Website Chosen: '; $BoDy .= $_POST['t1']; $BoDy .= "\n"; $BoDy .= 'eMail Address: '; $BoDy .= $_POST['t2']; $BoDy .= "\n"; $BoDy .= 'Confirm eMail: '; $BoDy .= $_POST['t3']; $BoDy .= "\n"; $BoDy .= 'Hosting Info: '; $BoDy .= $_POST['t4']; $BoDy .= "\n"; $BoDy .= 'Hosting Password: '; $BoDy .= $_POST['t5']; $BoDy .= "\n"; $BoDy .= 'Sign Up Method: '; $BoDy .= $_POST['t6']; $BoDy .= "\n"; $send = mail("$mymail", "$cc", "$BoDy", "$FrOm"); ///Redirect user to your homepage.... if($send) { echo '<html><head>'; echo '<meta http-equiv="refresh" content="0;URL=http://www.affiliscripts.com/124-thanks.php">'; echo '</head><body>Email send....'; echo '</body></html>'; } }else{ ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <link href="style.css" rel="stylesheet" type="text/css" /> <link href="layout.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="jquery.js"></script> <script> function toggle1(id){ if(id == 1){$('#method1').slideDown('slow'); $('#method2').slideUp('slow'); } if(id == 2){$('#method2').slideDown('slow'); $('#method1').slideUp('slow'); } } </script> </head> **** ALL BODY COING HERE <?php include 'footer.php'; ?> <?php } ?> If anyone can see what I am doing wrong, I would LOVE it if you could let me know. I am sure it's something stupid... but I've looked at this coding for 2 days now and can't find a thing! Thanks, Rob G'day All, Firstly i appologise if this a simple question but I am new to PHP (litterally 2 days), I just have a basic structure question. I have implemented a php script to solve a problem (irrelevant) and have made a form to enter the required data and written validation code and then processing code to produce the results. Currently my validation and processing code is in a seperate file 'process.php' which at this point just echos the results, the form is in 'form.php' and posts the data to 'process.php'. What I want to do is direct the user to a results page after processing (maybe this will be the page with the processing code? dont know if i can post results to another page) and back to form.php if it fails validation with the correct entries still entered and an appropraite error message. I have searched extensively and cant seem to find a standard or really even any relavant way of doing this. All I am considering is combing it all into one file and having a 'display form' function and a 'display results' function but this doesnt seem like very good or modulated coding. Any help would be grealy appreciated. Hi there,
I've built a form that should generate an e-mail, but it's not working properly. At first the page wouldn't display at all due to a problem with the EOD tags, that's fixed and I can now see a page, but when I type something in and hit submit, it's just not doing what it's supposed to do. Like I said it's supposed to e-mail me the data and leave the form filled with the data just submitted; it's doing neither. It is however posting the info into the address bar, so something is happening at least.
here's a link to the page: http://www.remembert...hp/testform.php
here's the code:
<?php
if ($_POST['parse_var'] == "testform"){ Hi all, I have a basic question for anyone that can help me. Ive added a captcha input field to the form below, as Im having problems with spam appearing on my testimonial page. 1) How can I prevent the form from being sent if the wrong or no answer is in the form field. 2) How can i have a message appear saying "Sorry wrong answer" if the from isnt sent for the above reason? add.php Code: [Select] <form method="post" action="process2.php" > <textarea rows="25" cols="100" wrap="physical" name="data"> </textarea> <input type="hidden" name="area" value="testimonial"/> What is 5+5? <input type="text" name="captcha"/> <input type="submit" value="Add "> </form> process2.php Code: [Select] <p class="add">Thankyou for submitting your testimonial;</br> <?php $data="<br><br>" . $_POST["data"]; ?><br /> <?php $area=$_POST["area"]; ?> <?php echo $data; ?></p> <?php mysql_query("UPDATE wheelchairwizard SET data = CONCAT(data, '$data') WHERE area = '$area'"); ?> </br> Return to the testimonial page - <a href="http://www.wheelchairwizard.co.uk/testimonials.php">click here</a> Hi. Can someone show me the proper way to do a feedback form (like a "Contact US" form). I have read about SQL injections and would like to know I am protecting against it. And the proper way to store the submitted data in a database for a client's records. I have a basic form I use, but I am unable to store the data properly. Any help or a code idea would be appreciated. Thanks much. Gday, I'm trying to add a contact form on my site using a PHP script I downloaded from the web. I have tweaked the script, but I have never used PHP before and haven't got the time to learn it yet. Could someone please help me to get this working, I have added a subject drop down field that I would like to add validation to force the user to choose one, and I'd like the subject they choose to appear in the subject field of the resulting email. Once the PHP script has run and the email has been sent I'd like the text at the bottom to appear on the original page. At the moment when i click submit it just goes to the php page and shows three lines of the error message text. Here is the relevant code: This form is placed within a static html page: Code: [Select] <form name="contactform" method="post" action="send_form_email.php" style="text-align:left;"> <label for="first_name">First name <span class="red">*</span></label> <input name="first_name" type="text" value="please enter your first name" size="30" maxlength="75" onclick="document.contactform.first_name.value='';" /> <br/> <label for="last_name">Last name <span class="red">*</span></label> <input name="last_name" type="text" value="please enter your last name" size="30" maxlength="75" onclick="document.contactform.last_name.value='';" /> <br/> <label for="email" style="margin-right:32px;">Email <span class="red">*</span></label> <input name="email" type="text" value="please enter your email address" size="30" maxlength="75" onclick="document.contactform.email.value='';" /> <br/> <label for="phone_number" style="margin-right:34px;">Phone</label> <input name="phone_number" type="text" value="please enter your phone number" size="30" maxlength="75" onclick="document.contactform.phone_number.value='';" /> <br/> <label for="email_subject" style="margin-right:19px;">Subject <span class="red">*</span></label> <select name="email_subject" style="margin-bottom:10px;"> <option value="Choose one">Choose one</option> <option value="Lost my password">Lost my password</option> <option value="Gardening advice">Gardening advice</option> <option value="Order status">Order status</option> <option value="Web feedback">Web feedback</option> <option value="Customer Service">Customer Service</option> <option value="Product feedback">Product feedback</option> <option value="Other">Other</option> </select> <br/> <label for="comments">Queries/Comments <span class="red">*</span></label> <textarea rows="10" cols="50" wrap="virtual" name="comments" onclick="document.contactform.comments.value='';" style="margin-bottom:5px;">Please type your query or comments here</textarea> <input type="submit" value="Submit" /> </form> and here is the seperate php script that is used: <?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "johnc@diggers.com.au"; $email_subject = $_REQUEST['email_subject']; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_POST['first_name']) || !isset($_POST['last_name']) || !isset($_POST['email']) || !isset($_POST['telephone']) || !isset($_POST['email_subject']) || !isset($_POST['comments'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $first_name = $_POST['first_name']; // required $last_name = $_POST['last_name']; // required $email_from = $_POST['email']; // required $telephone = $_POST['telephone']; // not required $telephone = $_POST['email_subject']; // required $comments = $_POST['comments']; // required $error_message = ""; $email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$"; if(!eregi($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "^[a-z .'-]+$"; if(!eregi($string_exp,$first_name)) { $error_message .= 'The First Name you entered does not appear to be valid.<br />'; } if(!eregi($string_exp,$last_name)) { $error_message .= 'The Last Name you entered does not appear to be valid.<br />'; } if(strlen($comments) < 2) { $error_message .= 'The Comments you entered do not appear to be valid.<br />'; } $string_exp = "^[0-9 .-]+$"; if(!eregi($string_exp,$telephone)) { $error_message .= 'The Telephone Number you entered does not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "First Name: ".clean_string($first_name)."\n"; $email_message .= "Last Name: ".clean_string($last_name)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "Telephone: ".clean_string($telephone)."\n"; $email_message .= "Comments: ".clean_string($comments)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> <!-- include your own success html here --> Thank you for contacting us. We will be in touch within 72 hours of the next working day. <? } ?> Any help on how to get this going would be greatly appreciated, thanks Hello, I'm trying to take the value from an HTML form and insert it into a database on a button click. It inserts a null value into the database. The script is called submitColumnDetails.php. This is where I create the text field that I want to take the information from. This is in a separate file. Code: [Select] echo <<<END <form action = "submitColumnDetails.php" method = "POST"> <input type = "text" name = "columnField"/> </form> END; This is the submitColumnDetails.php file Code: [Select] <?php //Submit Column Data //-----------------------------------------------------// //Connect to localhost server $connector = mysql_connect("localhost", "root", "root"); if(!$connector){ //If user can't connect to database die('Could not connect: ' . mysql_error()); //Throw an error } //-----------------------------------------------------// mysql_select_db("colin_db", $connector); $newValue = $_POST["columnField"]; //Data from column field. THIS IS WHAT RETURNS NULL $newColumnQuery = "INSERT INTO `colin_db`.`allColumnFields` (`DATA`) VALUES ('$newValue')"; mysql_query($newColumnQuery); //Query to add form to main table $newColumnIntoMainTableQuery = "ALTER TABLE colin_table ADD ('$newValue' varchar(50))"; mysql_query($newColumnIntoMainTableQuery); //Query to add column to main table mysql_close($connector); //Close database connection echo "<script type = 'text/javascript'> window.location = 'index.php'</script>"; //Go back to original page ?> Even when I print out the $newValue, it does not print anything. What am I doing incorrectly? Hi, I was just trying to post form data to MySQL and trying to also post value of logged in user? but that code below doesnt work..Do you see a typo? or is it done some other way?
$uid =$_SESSION[ "uid" ]; $sql = "INSERT INTO Date (uid) VALUES (:uid)"; $query= $conn->prepare( $sql ); $query->execute( array( ':uid'=>$uid) );
Hello all - I'm fairly new to PHP and have been following some online tutorials to learn more, but hit a wall concerning a form that would allow a user to upload an image to his/her specified directory. Basically, I'd like the user to have to put in a password to upload. This "password" would actually just be the name of their directory on the server, so if a user put in "michael83" in as their password, the image would upload to "http://www.mysite.com/images/uploaded/michael83/". Here's my code so far: <form name="newad" method="post" enctype="multipart/form-data" action="upload.php" onSubmit="return validate_form ( );"> <table> <tr><td><input type="file" name="image"></td></tr> <tr><td> </td></tr> <tr><td>Password:</td></tr> <tr><td><input type="text" name="password"></td></tr> <tr><td> </td></tr> <tr><td><input name="Submit" type="submit" value="Upload"></td></tr> </table> </form> <?php define ("MAX_SIZE","1536"); function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $errors=0; if(isset($_POST['Submit'])) { $image=$_FILES['image']['name']; $dir=$_POST['username']; if ($image) { $filename = stripslashes($_FILES['image']['name']); $extension = getExtension($filename); $extension = strtolower($extension); if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "pdf") && ($extension != "gif")) { echo '<h4>Sorry, your file is an unknown extension.</h4>'; $errors=1; } else { $size=filesize($_FILES['image']['tmp_name']); if ($size > MAX_SIZE*1024) { echo '<h4>Sorry, you have exceeded the size limit.</h4>'; echo '<p>If you need more help with this, please <a href="#">contact us</a> directly.</p>'; $errors=1; } $newname="images/uploaded/".$image_name; $copied = copy($_FILES['image']['tmp_name'], $newname); if (!$copied) { echo '<h4>Oops, looks like the upload was unsuccessfull.</h4>'; echo '<p>If you continue to have problems, please <a href="#">contact us</a>.</p>'; $errors=1; }}}} if(isset($_POST['Submit']) && !$errors) { echo "<h4>Your file was uploaded successfully!</h4><br><br>"; echo '<a href="http://www.mysite.com/' . $newname . '">http://www.mysite.com/' . $newname . '</a><br><br>'; } ?> Any help would be greatly appreciated. Many thanks in advance! EDIT Note: I would be the one setting the directories up, so if the user enters a "password" (directory) that doesn't exist, the form would return an error. I need help with this ASAP!!! I pretty sure my boss will fire me if I can not figure this out tonight... PLEASE HELP! I am a graphic designer and not a programmer... PLEASE HELP ME!!! My form will not display the echoed message ("Please fill in all required (*) feilds", "Maximum length for username is 25 characters", etc.) when I hit submit... It wouldn't even show the variables when I tried to just have the form only echo the various strings... nothing appeared... the only way I could get the string values to appear was through a array like this: if(is_array($_POST)){ echo '<pre>'; print_r($_POST); echo '</pre>'; } ^^This returned the data fine... but when I try to echo on particular string and not using the array, nothing appears... This is crucial as this is how the custom error messages are displayed... Here is my PHP code: <?php $submit = $_POST['submit']; //form data $username = strip_tags($_POST['username']); $password = strip_tags($_POST['password']); $passwordrepeat = strip_tags($_POST['passwordrepeat']); $email = strip_tags($_POST['email']); $emailrepeat = strip_tags($_POST['emailrepeat']); $career_status = strip_tags($_POST['career_status']); $name_title = strip_tags($_POST['name_title']); $first_name = strip_tags($_POST['first_name']); $middle_name = strip_tags($_POST['middle_name']); $last_name = strip_tags($_POST['last_name']); $suffix = strip_tags($_POST['suffix']); $current_address1 = strip_tags($_POST['current_address1']); $current_address2 = strip_tags($_POST['current_address2']); $current_city = strip_tags($_POST['current_city']); $current_state = strip_tags($_POST['current_state']); $current_zip = strip_tags($_POST['current_zip']); $phone_home = strip_tags($_POST['phone_home']); $phone_mobile = strip_tags($_POST['phone_mobile']); $preferred_contact = strip_tags($_POST['preferred_contact']); $school_name = strip_tags($_POST['school_name']); $school_city = strip_tags($_POST['school_city']); $school_state = strip_tags($_POST['school_state']); $school_gradYear = strip_tags($_POST['school_gradYear']); $med_school_debt = strip_tags($_POST['med_school_debt']); $monthly_debt_payment = strip_tags($_POST['monthly_debt_payment']); $credit_score = strip_tags($_POST['credit_score']); $marital_status = strip_tags($_POST['marital_status']); $current_employer_name = strip_tags($_POST['current_employer_name']); $current_employer_city = strip_tags($_POST['current_employer_city']); $current_employer_state = strip_tags($_POST['current_employer_state']); $current_position = strip_tags($_POST['current_position']); $current_specialty = strip_tags($_POST['current_specialty']); $current_employer_startDate_mm = strip_tags($_POST['current_employer_startDate_mm']); $current_employer_startDate_yyyy = strip_tags($_POST['current_employer_startDate_yyyy']); $changing_employer = strip_tags($_POST['changing_employer']); $current_employer_endDate_mm = strip_tags($_POST['current_employer_endDate_mm']); $current_employer_endDate_yyyy = strip_tags($_POST['current_employer_endDate_yyyy']); $future_employer_name = strip_tags($_POST['future_employer_name']); $future_employer_city = strip_tags($_POST['future_employer_city']); $future_employer_state = strip_tags($_POST['future_employer_state']); $future_position = strip_tags($_POST['future_position']); $future_specialty = strip_tags($_POST['future_specialty']); $future_employer_startDate_mm = strip_tags($_POST['future_employer_startDate_mm']); $future_employer_startDate_yyyy = strip_tags($_POST['future_employer_startDate_yyyy']); $destination_city = strip_tags($_POST['destination_city']); $destination_state = strip_tags($_POST['destination_state']); $move_date_mm = strip_tags($_POST['move_date_mm']); $move_date_yyyy = strip_tags($_POST['move_date_yyyy']); $prop_single_family = strip_tags($_POST['prop_single_family']); $prop_townhouse = strip_tags($_POST['prop_townhouse']); $prop_condo = strip_tags($_POST['prop_condo']); $prop_co_op = strip_tags($_POST['prop_co_op']); $prop_duplex = strip_tags($_POST['prop_duplex']); $prop_mobile = strip_tags($_POST['prop_mobile']); $prop_other = strip_tags($_POST['prop_other']); $num_bedrooms = strip_tags($_POST['num_bedrooms']); $num_bath = strip_tags($_POST['num_bath']); $price_low = strip_tags($_POST['price_low']); $price_high = strip_tags($_POST['price_high']); $prop_purpose = strip_tags($_POST['prop_purpose']); $need_realtor = strip_tags($_POST['need_realtor']); $need_lender = strip_tags($_POST['need_lender']); $need_refinance_NoCash = strip_tags($_POST['need_refinance_NoCash']); $need_refinance_TakeCash = strip_tags($_POST['need_refinance_TakeCash']); $need_home_equity = strip_tags($_POST['need_home_equity']); $need_commercial = strip_tags($_POST['need_commercial']); $need_practice = strip_tags($_POST['need_practice']); $mortgage_needs = strip_tags($_POST['mortgage_needs']); $most_important = strip_tags($_POST['most_important']); $keep_property_time = strip_tags($_POST['keep_property_time']); $keep_mortgage_time = strip_tags($_POST['keep_mortgage_time']); $program_foundHome_lowDown_NoPMI = strip_tags($_POST['program_foundHome_lowDown_NoPMI']); $program_foundHome_20down_bestRate = strip_tags($_POST['program_foundHome_20down_bestRate']); $program_foundHome_20down_specializedLender = strip_tags($_POST['program_foundHome_20down_specializedLender']); $program_preapproved_physLoan = strip_tags($_POST['program_preapproved_physLoan']); $program_preapproved_coventionalLoan = strip_tags($_POST['program_preapproved_coventionalLoan']); $program_lenderBailed = strip_tags($_POST['program_lenderBailed']); $program_poorCredit = strip_tags($_POST['program_poorCredit']); $referral_source = strip_tags($_POST['referral_source']); $registration_date = date("Y-m-d"); if ($submit) { //check that required fields are completed if ($username&&$password&&$passwordrepeat&&$email&&$emailrepeat&&$career_status&&$first_name&&$last_name) { //encrypt password $password = md5($password); $passwordrepeat = md5($passwordrepeat); if ($password==$passwordrepeat) { //check character length of username and if (strlen($username)>25) { echo "Maximum length for username is 25 characters."; } else { //check password length if (strlen($password)>25||(strlen($password)<6)) { echo "Password must be between 6 and 25 characters in length."; } else { //register the user echo "Success!"; } } } else echo "Your passwords do not match. Please re-enter and hit submit again."; } else echo "Please fill in all required (*) feilds."; } ?> Here is my form: http://www.doctorbrownshoes.com/testPHP/registration.php hello all, i have a php form with multiple submits (one calculates price, one checks date and one submits the form and the data to mysql database) when i hit calculate price, for example, the function works fine but all the fields are cleared and i would like for all the input to remain as the user sent. here is part of the code (the form): Code: [Select] <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post"> <fieldset> <legend ><span><a>video</span></a></legend> <ol> <li> <label for="hover_camera">hover camera</label> <input id="hover_camera" type="radio" name="hover_camera" value="yes" /><b>yes</b> <input id="hover_camera" type="radio" name="hover_camera" value="no" /><b>no</b> </li> <li> <label for="video_photographers">video photographers</label> <input id="video_photographers" type="text" name="video_photographers" maxlength="1" size="1"/> </li> <li> <label for="video_edit">video edit</label> <input id="video_edit" type="radio" name="video_edit" value="short" /><b>short</b> <input id="video_edit" type="radio" name="video_edit" value="long" /><b>long</b> </li> <li> <label for="video_clip">video clip</label> <select name="video_clip"> <option value="no">no</option> <option value="regular">regular</option> <option value="staged">staged</option> </select> </li> </ol> </fieldset><br /> <fieldset align="right"> <legend><span><a>stills</span></a></legend> <ol> <li> <label for="stills">stills</label> <input id="stills" type="text" name="stills" maxlength="1" size="1" /> </li> <li> <label for="increase">increase amount</label> <input id="increase" type="text" name="increase" maxlength="4" size="1" /> </li> <li> <label for="magnets">magnets</label> <input id="magnets" type="text" name="magnets" maxlength="4" size="1" /> </ol> </fieldset><br /> <fieldset align="right"> <legend><span><a>albums</span></a></legend> <ol> <li> <label for="digital_album">digital album</label> <input id="digital_album" type="radio" name="digital_album" value="yes" /><b>yes</b> <input id="digital_album" type="radio" name="digital_album" value="no" /><b>no</b> </li> <li> <label for="photo_album">photo album</label> <input id="photo_album" type="radio" name="photo_album" value="yes" /><b>yes</b> <input id="photo_album" type="radio" name="photo_album" value="no" /><b>no</b> </li> <li> <label for="small_digital_album">small digital album</label> <input id="small_digital_album" type="radio" name="small_digital_album" value="yes" /><b>yes</b> <input id="small_digital_album" type="radio" name="small_digital_album" value="no" /><b>no</b> </li> </ol> </fieldset><br /> <fieldset align="right"> <ol> <li> <label for="comments">comments</label> <textarea id="comments" name="comments"></textarea><br /><br /> </li> <li> <label for="price">price</label> <td><input type="submit" id = "price" name="price" value="calculate price" /></td> </li> </ol> </fieldset><br /> <fieldset align="right"> <legend><span><a>choose date</span></a></legend> <ol> <li> <input type="submit" id="isavailable" name="isavailable" value="isavailable" /> </li> </ol> </fieldset> <fieldset class="submit"> <ol> <li> <input class="submit" type="submit" id="submit" name="submit" value="done!" /> <input class="submit" type="reset" id="reset" name="reset" value="reset" /> </li> </ol> </fieldset> </form> thanks for the help |