emediastudios Posted May 25, 2008 Share Posted May 25, 2008 I have this code i had built and i want to use it in another site with a couple of alterations. I just want to take out "history" and "position applying for" The code works fine, but when i take out the pieces of code i think that should go, i get the returned error "failed to insert user data" This is the complete code <?php include_once('includes/include.php'); $pageTitle = "Join Our Team"; $upload_dir = "upload/"; //Experinced Users only Beyond this point except for formatting which will be commented $form = '<form enctype="multipart/form-data" action="upload_resume.php?submit=2" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="10240000" /> <input type="hidden" name="email" value="'.$_POST[email].'" /> Files must be of PDF format.<br>Max file size, one meg.<br><br>Attach Resume: <input name="uploadedfile" type="file" /><br /> <input type="submit" value="Upload File" /> </form>'; //FORMAT HERE //VERY IMPORTANT: make sure that you use " if the entire string is surrounded by ' and vice versa //otherwise you'll fuck yourself over //the table goes here $content3 .= '<table width="650">'; $content3 .= '<form method="post" action="upload_resume.php?submit=1">'; $content3 .= '<tr><td width="150">Name: </td><td width="150"><input type="text" style="width:175px" class="fields" name="name" value="'.$_POST[name].'" /></td></tr>'; $content3 .= '<tr><td width="150">Email Address: </td><td width="150"><input type="text" style="width:175px" class="fields" name="email" value="'.$_POST[email].'" /></td></tr>'; $content3 .= '<tr><td width="150">Contact Number: </td><td width="150"><input type="text" style="width:175px" class="fields" name="contact" value="'.$_POST[contact].'"/></td></tr>'; $content3 .= '<tr><td width="150">Mobile Number: </td><td width="150"><input type="text" style="width:175px" class="fields" name="mobile" value="'.$_POST[mobile].'"/></td></tr>'; $content3 .= '<tr><td width="150">Address Line 1: </td><td width="150"><input type="text" style="width:175px" class="fields" name="ad1" value="'.$_POST[ad1].'"/></td></tr>'; $content3 .= '<tr><td width="150">Address Line 2: </td><td width="150"><input type="text" style="width:175px" class="fields" name="ad2" value="'.$_POST[ad2].'"/></td></tr>'; $content3 .= '<tr><td width="150">City: </td><td width="150"><input type="text" style="width:175px" class="fields" name="city" value="'.$_POST[city].'"/></td></tr>'; $content3 .= '<tr><td width="150">State: </td><td width="150" class="fields1">'; $content3 .= '<select name="state" style="width:179px" class="fields"> <option value="">Please Select</option> <option value="NSW"'; if($_POST[state] == "NSW") $content3 .= " selected='selected'"; $content3 .= '>New South Wales</option> <option value="NT"'; if($_POST[state] == "NT") $content3 .= " selected='selected'"; $content3 .= '>Northern Territory</option> <option value="QLD'; if($_POST[state] == "QLD") $content3 .= " selected='selected'"; $content3 .= '">Queensland</option> <option value="SA"'; if($_POST[state] == "SA") $content3 .= " selected='selected'"; $content3 .= '>South Australia</option> <option value="TAS"'; if($_POST[state] == "TAS") $content3 .= " selected='selected'"; $content3 .= '>Tasmania</option> <option value="VIC"'; if($_POST[state] == "VIC") $content3 .= " selected='selected'"; $content3 .= '>Victoria</option> <option value="WA"'; if($_POST[state] == "WA") $content3 .= " selected='selected'"; $content3 .= '>Western Australia</option> </select></td></tr> '; $content3 .= '<tr><td width="150">Zip Code: </td><td width="150"><input type="text" style="width:175px" class="fields" name="post" value="'.$_POST[post].'" /></td></tr>'; $content3 .='<tr><td width="150">Date Of Birth: </td><td width="150">'; $content3 .=' <select name="dateofbirthday"> <option value="">DD</option>'; for($i = 1; $i <= 31; $i++) { if(strlen($i) < 1) $i = '0' . $i; if($_POST[dateofbirthday] == $i) $selection = " selected='selected'"; $content3 .= '<option value="'. $i .'" '.$selection.'>'. $i .'</option>'; } $content3 .='</select> <select name="dateofmonth"> <option value="">MM</option>'; for($i = 1; $i <= 12; $i++) { if(strlen($i) < 1) $i = '0' . $i; if($_POST[dateofmonth] == $i) $selection = " selected='selected'"; $content3 .= '<option value="'. $i .'" '.$selection.'>'. $i .'</option>'; } $content3 .='</select> <select name="dateofbirthyear"> <option value="">YYYY</option>'; for($i = date('Y') - 100; $i <= date('Y') - 16; $i++) { if($_POST[dateofbirthyear] == $i) $selection = " selected='selected'"; $content3 .= '<option value="'. $i .'" '.$selection.'>'. $i .'</option>'; } $content3 .='</select></td></tr>'; $content3 .= '<tr><td width="150">Position Applying For: </td><td width="150"><input type="text" style="width:175px" class="fields" name="position" value="'.$_POST[position].'"/></td></tr>'; $content3 .= '<tr><td colspan="2">History: </td></tr><tr><td colspan="2"><textarea name="history" cols=35 rows=8>'.$_POST[history].'</textarea></td></tr>'; $content3 .= '<tr><td colspan="2" align="left"><input type="submit" value="Next"/></td></tr></form></table>'; if($_GET['submit'] == ""){ $content .= $content3; } else if($_GET[submit] == '1'){ //the mysql goes here if(!EmailChk($_POST[email])){$kill=1; $content2 .= "Invalid Email Address<br>";} if(!EmailCheck($_POST[email])){$kill=1; $content2 .= "Duplicate Email Address<br>";} if($_POST[contact] == ""){$kill=1; $content2 .= "Enter a Phone Number (Normal)<br>";} if($_POST[mobile] == ""){$kill=1; $content2 .= "Enter a Phone Number (Mobile)<br>";} if($_POST[dateofmonth] == ""){$kill=1; $content2 .= "Enter a Birth Month<br>";} if($_POST[dateofbirthday] == ""){$kill=1; $content2 .= "Enter a Birth Day<br>";} if($_POST[dateofbirthyear] == ""){$kill=1; $content2 .= "Enter a Birth Year<br>";} if($_POST[state] == ""){$kill=1; $content2 .= "Enter a State<br>";} if($_POST[name] == ""){$kill=1; $content2 .= "Enter a Name<br>";} if($_POST[city] == ""){$kill=1; $content2 .= "Enter a City<br>";} if($_POST[ad1] == ""){$kill=1; $content2 .= "Enter an Address<br>";} if($_POST[post] == ""){$kill=1; $content2 .= "Enter a Postal Code<br>";} if($_POST[history] == ""){$kill=1; $content2 .= "Enter work History<br>";} if($kill != 1){ $_POST[address] = $_POST[ad1] . "\n" . $_POST[ad2]; $_POST[ad1] = ""; $_POST[ad2] = ""; $_POST[dob] = $_POST[dateofmonth] . "/" . $_POST[dateofbirthday] . "/" . $_POST[dateofbirthyear]; $_POST[dateofmonth] = ""; $_POST[dateofbirthyear] = ""; $_POST[dateofbirthday] = ""; $q = "INSERT INTO resume(name,dob,address,city,state,post,contact,mobile,position,history,email,file) VALUES ('".$_POST[name]."','".$_POST[dob]."','".$_POST[address]."','".$_POST[city]."','".$_POST[state]."','".$_POST[post]."','".$_POST[contact]."','".$_POST[mobile]."','".$_POST[position]."','".$_POST[history]."','".$_POST[email]."','')"; if(!mysql_query($q)) $content .= "failed to insert user data"; else{ $content .= $form; } } else $content.= $content2 . "<br><br><br>" . $content3; } else if($_GET[submit] == '2'){ $target_path = $upload_dir; while(file_exists($target_path)){ $random3 = (rand()%999999); $target_path = $target_path . $random3 . basename( $_FILES['uploadedfile']['name']); } if(strtolower($_FILES['uploadedfile']['name']) != str_replace(".pdf", "", strtolower($_FILES['uploadedfile']['name']))){ if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { $content .= "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded for email address:<br> ". $_POST[email]; mysql_query("UPDATE resume SET file = '".$target_path."' WHERE email='".$_POST[email]."'"); mail("[email protected]","New Employment Application at your website", "Please go to your website to see the application", "From: [email protected]"); } else{ $content .= 'There was an error uploading the file, please try again!<br>'; $content .= $form; } } else{ $content .= 'Must Be A .pdf File<br>'; $content .= $form; } } $pageTitle = "Join Our Team"; include('employment.php'); ?> I thought i could take out these sections of code, but errors for me ??? $content3 .='</select></td></tr>'; $content3 .= '<tr><td width="150">Position Applying For: </td><td width="150"><input type="text" style="width:175px" class="fields" name="position" value="'.$_POST[position].'"/></td></tr>'; $content3 .= '<tr><td colspan="2">History: </td></tr><tr><td colspan="2"><textarea name="history" cols=35 rows=8>'.$_POST[history].'</textarea></td></tr>'; if($_POST[post] == ""){$kill=1; $content2 .= "Enter a Postal Code<br>";} if($_POST[history] == ""){$kill=1; $content2 .= "Enter work History<br>";} position,history, '".$_POST[position]."','".$_POST[history]."' Link to comment https://forums.phpfreaks.com/topic/107158-alter-my-code/ Share on other sites More sharing options...
runnerjp Posted May 25, 2008 Share Posted May 25, 2008 here you go... did this one free! <?php include_once('includes/include.php'); $pageTitle = "Join Our Team"; $upload_dir = "upload/"; //Experinced Users only Beyond this point except for formatting which will be commented $form = '<form enctype="multipart/form-data" action="upload_resume.php?submit=2" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="10240000" /> <input type="hidden" name="email" value="'.$_POST[email].'" /> Files must be of PDF format.<br>Max file size, one meg.<br><br>Attach Resume: <input name="uploadedfile" type="file" /><br /> <input type="submit" value="Upload File" /> </form>'; //FORMAT HERE //VERY IMPORTANT: make sure that you use " if the entire string is surrounded by ' and vice versa //otherwise you'll fuck yourself over //the table goes here $content3 .= '<table width="650">'; $content3 .= '<form method="post" action="upload_resume.php?submit=1">'; $content3 .= '<tr><td width="150">Name: </td><td width="150"><input type="text" style="width:175px" class="fields" name="name" value="'.$_POST[name].'" /></td></tr>'; $content3 .= '<tr><td width="150">Email Address: </td><td width="150"><input type="text" style="width:175px" class="fields" name="email" value="'.$_POST[email].'" /></td></tr>'; $content3 .= '<tr><td width="150">Contact Number: </td><td width="150"><input type="text" style="width:175px" class="fields" name="contact" value="'.$_POST[contact].'"/></td></tr>'; $content3 .= '<tr><td width="150">Mobile Number: </td><td width="150"><input type="text" style="width:175px" class="fields" name="mobile" value="'.$_POST[mobile].'"/></td></tr>'; $content3 .= '<tr><td width="150">Address Line 1: </td><td width="150"><input type="text" style="width:175px" class="fields" name="ad1" value="'.$_POST[ad1].'"/></td></tr>'; $content3 .= '<tr><td width="150">Address Line 2: </td><td width="150"><input type="text" style="width:175px" class="fields" name="ad2" value="'.$_POST[ad2].'"/></td></tr>'; $content3 .= '<tr><td width="150">City: </td><td width="150"><input type="text" style="width:175px" class="fields" name="city" value="'.$_POST[city].'"/></td></tr>'; $content3 .= '<tr><td width="150">State: </td><td width="150" class="fields1">'; $content3 .= '<select name="state" style="width:179px" class="fields"> <option value="">Please Select</option> <option value="NSW"'; if($_POST[state] == "NSW") $content3 .= " selected='selected'"; $content3 .= '>New South Wales</option> <option value="NT"'; if($_POST[state] == "NT") $content3 .= " selected='selected'"; $content3 .= '>Northern Territory</option> <option value="QLD'; if($_POST[state] == "QLD") $content3 .= " selected='selected'"; $content3 .= '">Queensland</option> <option value="SA"'; if($_POST[state] == "SA") $content3 .= " selected='selected'"; $content3 .= '>South Australia</option> <option value="TAS"'; if($_POST[state] == "TAS") $content3 .= " selected='selected'"; $content3 .= '>Tasmania</option> <option value="VIC"'; if($_POST[state] == "VIC") $content3 .= " selected='selected'"; $content3 .= '>Victoria</option> <option value="WA"'; if($_POST[state] == "WA") $content3 .= " selected='selected'"; $content3 .= '>Western Australia</option> </select></td></tr> '; $content3 .= '<tr><td width="150">Zip Code: </td><td width="150"><input type="text" style="width:175px" class="fields" name="post" value="'.$_POST[post].'" /></td></tr>'; $content3 .='<tr><td width="150">Date Of Birth: </td><td width="150">'; $content3 .=' <select name="dateofbirthday"> <option value="">DD</option>'; for($i = 1; $i <= 31; $i++) { if(strlen($i) < 1) $i = '0' . $i; if($_POST[dateofbirthday] == $i) $selection = " selected='selected'"; $content3 .= '<option value="'. $i .'" '.$selection.'>'. $i .'</option>'; } $content3 .='</select> <select name="dateofmonth"> <option value="">MM</option>'; for($i = 1; $i <= 12; $i++) { if(strlen($i) < 1) $i = '0' . $i; if($_POST[dateofmonth] == $i) $selection = " selected='selected'"; $content3 .= '<option value="'. $i .'" '.$selection.'>'. $i .'</option>'; } $content3 .='</select> <select name="dateofbirthyear"> <option value="">YYYY</option>'; for($i = date('Y') - 100; $i <= date('Y') - 16; $i++) { if($_POST[dateofbirthyear] == $i) $selection = " selected='selected'"; $content3 .= '<option value="'. $i .'" '.$selection.'>'. $i .'</option>'; } $content3 .='</select></td></tr>'; $content3 .= '<tr><td colspan="2" align="left"><input type="submit" value="Next"/></td></tr></form></table>'; if($_GET['submit'] == ""){ $content .= $content3; } else if($_GET[submit] == '1'){ //the mysql goes here if(!EmailChk($_POST[email])){$kill=1; $content2 .= "Invalid Email Address<br>";} if(!EmailCheck($_POST[email])){$kill=1; $content2 .= "Duplicate Email Address<br>";} if($_POST[contact] == ""){$kill=1; $content2 .= "Enter a Phone Number (Normal)<br>";} if($_POST[mobile] == ""){$kill=1; $content2 .= "Enter a Phone Number (Mobile)<br>";} if($_POST[dateofmonth] == ""){$kill=1; $content2 .= "Enter a Birth Month<br>";} if($_POST[dateofbirthday] == ""){$kill=1; $content2 .= "Enter a Birth Day<br>";} if($_POST[dateofbirthyear] == ""){$kill=1; $content2 .= "Enter a Birth Year<br>";} if($_POST[state] == ""){$kill=1; $content2 .= "Enter a State<br>";} if($_POST[name] == ""){$kill=1; $content2 .= "Enter a Name<br>";} if($_POST[city] == ""){$kill=1; $content2 .= "Enter a City<br>";} if($_POST[ad1] == ""){$kill=1; $content2 .= "Enter an Address<br>";} if($kill != 1){ $_POST[address] = $_POST[ad1] . "\n" . $_POST[ad2]; $_POST[ad1] = ""; $_POST[ad2] = ""; $_POST[dob] = $_POST[dateofmonth] . "/" . $_POST[dateofbirthday] . "/" . $_POST[dateofbirthyear]; $_POST[dateofmonth] = ""; $_POST[dateofbirthyear] = ""; $_POST[dateofbirthday] = ""; $q = "INSERT INTO resume(name,dob,address,city,state,post,contact,mobile,email,file) VALUES ('".$_POST[name]."','".$_POST[dob]."','".$_POST[address]."','".$_POST[city]."','".$_POST[state]."','".$_POST[post]."','".$_POST[contact]."','".$_POST[mobile]."','".$_POST[email]."','')"; if(!mysql_query($q)) $content .= "failed to insert user data"; else{ $content .= $form; } } else $content.= $content2 . "<br><br><br>" . $content3; } else if($_GET[submit] == '2'){ $target_path = $upload_dir; while(file_exists($target_path)){ $random3 = (rand()%999999); $target_path = $target_path . $random3 . basename( $_FILES['uploadedfile']['name']); } if(strtolower($_FILES['uploadedfile']['name']) != str_replace(".pdf", "", strtolower($_FILES['uploadedfile']['name']))){ if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { $content .= "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded for email address:<br> ". $_POST[email]; mysql_query("UPDATE resume SET file = '".$target_path."' WHERE email='".$_POST[email]."'"); mail("[email protected]","New Employment Application at your website", "Please go to your website to see the application", "From: [email protected]"); } else{ $content .= 'There was an error uploading the file, please try again!<br>'; $content .= $form; } } else{ $content .= 'Must Be A .pdf File<br>'; $content .= $form; } } $pageTitle = "Join Our Team"; include('employment.php'); ?> ... am i doing i right? Link to comment https://forums.phpfreaks.com/topic/107158-alter-my-code/#findComment-549412 Share on other sites More sharing options...
emediastudios Posted May 25, 2008 Author Share Posted May 25, 2008 Same error i get failed to insert user data Thanks for trying Link to comment https://forums.phpfreaks.com/topic/107158-alter-my-code/#findComment-549417 Share on other sites More sharing options...
runnerjp Posted May 25, 2008 Share Posted May 25, 2008 it thiat case chnage this if(!mysql_query($q)) $content .= "failed to insert user data"; to this )$query = "INSERT INTO resume(name,dob,address,city,state,post,contact,mobile,email,file) VALUES ('".$_POST[name]."','".$_POST[dob]."','".$_POST[address]."','".$_POST[city]."','".$_POST[state]."','".$_POST[post]."','".$_POST[contact]."','".$_POST[mobile]."','".$_POST[email]."','')"; mysql_query($query) or die("Query failed: " . mysql_error()); Link to comment https://forums.phpfreaks.com/topic/107158-alter-my-code/#findComment-549424 Share on other sites More sharing options...
emediastudios Posted May 25, 2008 Author Share Posted May 25, 2008 had no luck ??? Link to comment https://forums.phpfreaks.com/topic/107158-alter-my-code/#findComment-549426 Share on other sites More sharing options...
AndyB Posted May 25, 2008 Share Posted May 25, 2008 $q = "INSERT INTO resume(name,dob,address,city,state,post,contact,mobile,email,file) VALUES ('".$_POST[name]."','".$_POST[dob]."','".$_POST[address]."','".$_POST[city]."','".$_POST[state]."','".$_POST[post]."','".$_POST[contact]."','".$_POST[mobile]."','".$_POST[email]."','')"; 10 fields listed 9 values stated If you had error-trapping, it would have jumped out at you Link to comment https://forums.phpfreaks.com/topic/107158-alter-my-code/#findComment-549456 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.