-
Posts
9,409 -
Joined
-
Last visited
-
Days Won
1
Everything posted by MadTechie
-
Okay you can do this a few ways to redirect but i use header so.. heres an update <?php require ('database.php'); if(!empty($_GET['action']) && $_GET['action']=='delete') { $query = "DELETE FROM shows WHERE id = '".$_GET['id']."'"; if(mysql_query($query)) { echo "Deletion successful."; }else{ die ('<p>Could not delete post because ' . mysql_error() . '. The query was '."$query.".'</p>'); } header("http://www.".$_SERVER["HTTP_HOST"].$_SERVER['PHP_SELF']); // you may need to tweak this line } /* addshowname.php */ /* This form after submission takes the results of the form and inserts the values into the database as a new show name is created. */ require ('style.css'); //This code runs if the form has been submitted if (isset($_POST['submit'])) { $error = true; if(!empty($_FILES['uploadedfile']['name'])) { // Where the file is going to be placed $target_path = "../defiant/images/"; /* Add the original filename to our target path. Result is "images/filename.extension" */ $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); $image = $_FILES['uploadedfile']['name']; $extension = explode(".", $image); $extension = $extension[count($extension)-1]; if(strtolower($extension) == "jpg") { if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file ".basename( $_FILES['uploadedfile']['name'])." has been uploaded"; $error = false; }else{ echo "There was an error uploading the file, please try again!"; } }else{ echo "The file you chose to upload wasn't a valid jpg file, please try again!"; } }else{ echo "No File uploaded, please try again!"; } if(!$error && !empty($_POST['showname']) && !empty($_POST['type'])) { // checks if the show name is in use if (!get_magic_quotes_gpc()) { $_POST['showname'] = addslashes($_POST['showname']); } $showname = $_POST['showname']; $check = mysql_query("SELECT showname FROM shows WHERE showname = '$showname'") or die(mysql_error()); $check2 = mysql_num_rows($check); //if the name exists it gives an error if ($check2 != 0) { die('Sorry, the show name '.$_POST['showname'].' is already in use.'); } // now we insert it into the database $insert = "INSERT INTO shows (showname, type, showimage, showlabel) VALUES ('".$_POST['showname']."','".$_POST['type']."','$target_path','1')"; $add_show = mysql_query($insert) or die(mysql_error()); } } print '<center><caption><strong>Add A Show</strong></caption></center>'; print '<form enctype="multipart/form-data" method="post">'; print '<input name="MAX_FILE_SIZE" type="hidden" value="100000">'; print '<table border="1" style="margin: auto; width: 60%;">'; print '<tr><td>Enter Show Name:</td> '; print '<td><input name="showname" type="text"></td></tr>'; print '<tr><td>Show Type:</td> '; print '<td><select name="type"><option></option><option>Weekly Show</option><option>Pay Per View</option></select></td></tr>'; print '<tr><td>Show Image:</td> '; print '<td><input name="uploadedfile" type="file"></td></tr>'; print '<tr><th colspan=2><input type="submit" name="submit" value="Add Show Name" /><input name="sumbitted" type="hidden" value="TRUE"></th></tr></table></form><br><br><br>'; print '<center><caption><strong>List of Shows</strong></caption></center>'; print '<table width="60%" border="1" align="center">'; print '<tr><th align="center">ID</th><th align="center">Type</th><th align="center">Show Name</th><th align="center">Show Image</th><th align="center">Edit</th><th align="center">Delete</th></tr>'; if(!isset($_GET['action']) && !isset($_POST['name'])) { //Define the query $query = "SELECT * FROM shows"; if ($r = mysql_query ($query)) // Run the query. { if (mysql_num_rows($r) > 0) { // Retrieve and print every record while ($row = mysql_fetch_array ($r)) { print '<tr><td align="center">'.$row['id'].'</td><td align="center">'.$row['type'].'</td><td align="center">'.$row['showname'].'</td><td align="center">'.$row['showimage'].'</td><td align="center"><a href="addshowname.php?action=edit&id='.$row['id'].'"<center>Edit</center></a></td><td align="center"><a href="addshowname.php?action=delete&id='.$row['id'].'">Delete</a></td></tr>'; } }else{ print "No Shows\n"; } }else{ die ('<p>Could not retrieve the data because <b>' . mysql_error() . '</b>. The query was '."$query.".'</p>'); } //End of query IF print '</table>'; } if(!empty($_GET['action']) && !empty($_GET['id'])) { switch($_GET['action']) { case 'edit': $query = "SELECT * FROM shows WHERE id = '".$_GET['id']."'"; $res = mysql_fetch_array(mysql_query($query)); print('<form action="'.$_SERVER['PHP_SELF'].'" method="post" name="form1">'); print('<table border=1 cellpadding=5 cellspacing=0 width=350>'); print('<tr><td>Name of show:</td><td><input type="text" name="name" value="'.$res['showname'].'"/></td></tr>'); print('<tr><td>Show Type Type:</td><td><select name="type">'); $types = array('Weekly Show','Pay Per View'); foreach($types as $type) { if($type == $res['type']) { print('<option value="'.$type.'" selected="selected">'.$type.'</option>'); }else{ print('<option value="'.$type.'">'.$type.'</option>'); } } print('</select></td></tr>'); print('<tr><th colspan=2><input type="hidden" name="id" value="'.$_GET['id'].'" /><input type="submit" value="Edit Show" /></th></tr></table></form></center>'); break; } } if(!empty($_POST['name']) && !empty($_POST['loc']) && !empty($_POST['date']) && !empty($_POST['id'])) { $query = "UPDATE shows SET showname = '".mysql_real_escape_string($_POST['name'])."', location = '".mysql_real_escape_string($_POST['loc'])."', date = '".mysql_real_escape_string($_POST['date'])."' WHERE id = '".$_POST['id']."'"; if(mysql_query($query)) { echo "Show updated."; }else{ die('<p>The show could not update because <b>' . mysql_error() . '</b>. The query was '."$query.".'</p>'); } } ?>
-
After a freash install i would do this sudo dpkg --configure -a sudo apt-get clean all sudo apt-get update maybe even sudo apt-get upgrade however.. if your using packages that are not include in the normal install why not get all of them then before you install ? as a side note this is the wrong section
-
Cool just one thing remains.. clicking solved to end this thread
-
ooops, forgot the else change this echo "The file you chose to upload wasn't a valid jpg file, please try again!"; } echo "No File uploaded, please try again!"; } to echo "The file you chose to upload wasn't a valid jpg file, please try again!"; } }else{ //<---add this echo "No File uploaded, please try again!"; }
-
Okay.. heres a clean up please read the code and check it makes sense as i have added quite a few error checks <?php /* addshowname.php */ /* This form after submission takes the results of the form and inserts the values into the database as a new show name is created. */ require ('database.php'); require ('style.css'); //This code runs if the form has been submitted if (isset($_POST['submit'])) { $error = true; if(!empty($_FILES['uploadedfile']['name'])) { // Where the file is going to be placed $target_path = "../defiant/images/"; /* Add the original filename to our target path. Result is "images/filename.extension" */ $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); $image = $_FILES['uploadedfile']['name']; $extension = explode(".", $image); $extension = $extension[count($extension)-1]; if(strtolower($extension) == "jpg") { if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file ".basename( $_FILES['uploadedfile']['name'])." has been uploaded"; $error = false; }else{ echo "There was an error uploading the file, please try again!"; } }else{ echo "The file you chose to upload wasn't a valid jpg file, please try again!"; } echo "No File uploaded, please try again!"; } if(!$error && !empty($_POST['showname']) && !empty($_POST['type'])) { // checks if the show name is in use if (!get_magic_quotes_gpc()) { $_POST['showname'] = addslashes($_POST['showname']); } $showname = $_POST['showname']; $check = mysql_query("SELECT showname FROM shows WHERE showname = '$showname'") or die(mysql_error()); $check2 = mysql_num_rows($check); //if the name exists it gives an error if ($check2 != 0) { die('Sorry, the show name '.$_POST['showname'].' is already in use.'); } // now we insert it into the database $insert = "INSERT INTO shows (showname, type, showimage, showlabel) VALUES ('".$_POST['showname']."','".$_POST['type']."','$target_path','1')"; $add_show = mysql_query($insert) or die(mysql_error()); } } print '<center><caption><strong>Add A Show</strong></caption></center>'; print '<form enctype="multipart/form-data" method="post">'; print '<input name="MAX_FILE_SIZE" type="hidden" value="100000">'; print '<table border="1" style="margin: auto; width: 60%;">'; print '<tr><td>Enter Show Name:</td> '; print '<td><input name="showname" type="text"></td></tr>'; print '<tr><td>Show Type:</td> '; print '<td><select name="type"><option></option><option>Weekly Show</option><option>Pay Per View</option></select></td></tr>'; print '<tr><td>Show Image:</td> '; print '<td><input name="uploadedfile" type="file"></td></tr>'; print '<tr><th colspan=2><input type="submit" name="submit" value="Add Show Name" /><input name="sumbitted" type="hidden" value="TRUE"></th></tr></table></form><br><br><br>'; print '<center><caption><strong>List of Shows</strong></caption></center>'; print '<table width="60%" border="1" align="center">'; print '<tr><th align="center">ID</th><th align="center">Type</th><th align="center">Show Name</th><th align="center">Show Image</th><th align="center">Edit</th><th align="center">Delete</th></tr>'; if(!isset($_GET['action']) && !isset($_POST['name'])) { //Define the query $query = "SELECT * FROM shows"; if ($r = mysql_query ($query)) // Run the query. { if (mysql_num_rows($r) > 0) { // Retrieve and print every record while ($row = mysql_fetch_array ($r)) { print '<tr><td align="center">'.$row['id'].'</td><td align="center">'.$row['type'].'</td><td align="center">'.$row['showname'].'</td><td align="center">'.$row['showimage'].'</td><td align="center"><a href="addshowname.php?action=edit&id='.$row['id'].'"<center>Edit</center></a></td><td align="center"><a href="addshowname.php?action=delete&id='.$row['id'].'">Delete</a></td></tr>'; } }else{ print "No Shows\n"; } }else{ die ('<p>Could not retrieve the data because <b>' . mysql_error() . '</b>. The query was '."$query.".'</p>'); } //End of query IF print '</table>'; } if(!empty($_GET['action']) && !empty($_GET['id'])) { switch($_GET['action']) { case 'edit': $query = "SELECT * FROM shows WHERE id = '".$_GET['id']."'"; $res = mysql_fetch_array(mysql_query($query)); print('<form action="'.$_SERVER['PHP_SELF'].'" method="post" name="form1">'); print('<table border=1 cellpadding=5 cellspacing=0 width=350>'); print('<tr><td>Name of show:</td><td><input type="text" name="name" value="'.$res['showname'].'"/></td></tr>'); print('<tr><td>Show Type Type:</td><td><select name="type">'); $types = array('Weekly Show','Pay Per View'); foreach($types as $type) { if($type == $res['type']) { print('<option value="'.$type.'" selected="selected">'.$type.'</option>'); }else{ print('<option value="'.$type.'">'.$type.'</option>'); } } print('</select></td></tr>'); print('<tr><th colspan=2><input type="hidden" name="id" value="'.$_GET['id'].'" /><input type="submit" value="Edit Show" /></th></tr></table></form></center>'); break; case 'delete': $query = "DELETE FROM shows WHERE id = '".$_GET['id']."'"; if(mysql_query($query)) { echo "Deletion successful."; }else{ die ('<p>Could not delete post because ' . mysql_error() . '. The query was '."$query.".'</p>'); } break; } } if(!empty($_POST['name']) && !empty($_POST['loc']) && !empty($_POST['date']) && !empty($_POST['id'])) { $query = "UPDATE shows SET showname = '".mysql_real_escape_string($_POST['name'])."', location = '".mysql_real_escape_string($_POST['loc'])."', date = '".mysql_real_escape_string($_POST['date'])."' WHERE id = '".$_POST['id']."'"; if(mysql_query($query)) { echo "Show updated."; }else{ die('<p>The show could not update because <b>' . mysql_error() . '</b>. The query was '."$query.".'</p>'); } } ?>
-
I added an if statement to help Please see the 3 $error lines $error = true; $error = false; if(!$error); in your code, i formatted a little as it was a pain to read <?php /* addshowname.php */ /* This form after submission takes the results of the form and inserts the values into the database as a new show name is created. */ require ('database.php'); require ('style.css'); // Where the file is going to be placed $target_path = "../defiant/images/"; /* Add the original filename to our target path. Result is "images/filename.extension" */ $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); //This code runs if the form has been submitted if (isset($_POST['submit'])) { $error = true; $image = $_FILES['uploadedfile']['name']; $extension = explode(".", $image); $extension = $extension[count($extension)-1]; if(strtolower($extension) == "jpg") { if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file ".basename( $_FILES['uploadedfile']['name'])." has been uploaded"; $error = false; }else{ echo "There was an error uploading the file, please try again!"; } }else{ echo "The file you chose to upload wasn't a valid jpg file, please try again!"; } if(!$error) { // checks if the show name is in use if (!get_magic_quotes_gpc()) { $_POST['showname'] = addslashes($_POST['showname']); } $showname = $_POST['showname']; $check = mysql_query("SELECT showname FROM shows WHERE showname = '$showname'") or die(mysql_error()); $check2 = mysql_num_rows($check); //if the name exists it gives an error if ($check2 != 0) { die('Sorry, the show name '.$_POST['showname'].' is already in use.'); } // now we insert it into the database $insert = "INSERT INTO shows (showname, type, showimage, showlabel) VALUES ('".$_POST['showname']."','".$_POST['type']."','$target_path','1')"; $add_show = mysql_query($insert) or die(mysql_error()); } } print '<center><caption><strong>Add A Show</strong></caption></center>'; print '<form enctype="multipart/form-data" method="post">'; print '<input name="MAX_FILE_SIZE" type="hidden" value="100000">'; print '<table border="1" style="margin: auto; width: 60%;">'; print '<tr><td>Enter Show Name:</td> '; print '<td><input name="showname" type="text"></td></tr>'; print '<tr><td>Show Type:</td> '; print '<td><select name="type"><option></option><option>Weekly Show</option><option>Pay Per View</option></select></td></tr>'; print '<tr><td>Show Image:</td> '; print '<td><input name="uploadedfile" type="file"></td></tr>'; print '<tr><th colspan=2><input type="submit" name="submit" value="Add Show Name" /><input name="sumbitted" type="hidden" value="TRUE"></th></tr></table></form><br><br><br>'; print '<center><caption><strong>List of Shows</strong></caption></center>'; print '<table width="60%" border="1" align="center">'; print '<tr><th align="center">ID</th><th align="center">Type</th><th align="center">Show Name</th><th align="center">Show Image</th><th align="center">Edit</th><th align="center">Delete</th></tr>'; if(!isset($_GET['action']) && !isset($_POST['name'])) { //Define the query $query = "SELECT * FROM shows"; if ($r = mysql_query ($query)) // Run the query. { if (mysql_num_rows($r) > 0) { // Retrieve and print every record while ($row = mysql_fetch_array ($r)) { print '<tr><td align="center">'.$row['id'].'</td><td align="center">'.$row['type'].'</td><td align="center">'.$row['showname'].'</td><td align="center">'.$row['showimage'].'</td><td align="center"><a href="addshowname.php?action=edit&id='.$row['id'].'"<center>Edit</center></a></td><td align="center"><a href="addshowname.php?action=delete&id='.$row['id'].'">Delete</a></td></tr>'; } }else{ print "No Shows\n"; } }else{ die ('<p>Could not retrieve the data because <b>' . mysql_error() . '</b>. The query was '."$query.".'</p>'); } //End of query IF print '</table>'; } if($_GET['action'] == 'edit') { $query = "SELECT * FROM shows WHERE id = '".$_GET['id']."'"; $res = mysql_fetch_array(mysql_query($query)); print('<form action="'.$_SERVER['PHP_SELF'].'" method="post" name="form1">'); print('<table border=1 cellpadding=5 cellspacing=0 width=350>'); print('<tr><td>Name of show:</td><td><input type="text" name="name" value="'.$res['showname'].'"/></td></tr>'); print('<tr><td>Show Type Type:</td><td><select name="type">'); $types = array('Weekly Show','Pay Per View'); foreach($types as $type) { if($type == $res['type']) { print('<option value="'.$type.'" selected="selected">'.$type.'</option>'); }else{ print('<option value="'.$type.'">'.$type.'</option>'); } } print('</select></td></tr>'); print('<tr><th colspan=2><input type="hidden" name="id" value="'.$_GET['id'].'" /><input type="submit" value="Edit Show" /></th></tr></table></form></center>'); } if(isset($_POST['name'])) { $query = "UPDATE shows SET showname = '".mysql_real_escape_string($_POST['name'])."', location = '".mysql_real_escape_string($_POST['loc'])."', date = '".mysql_real_escape_string($_POST['date'])."' WHERE id = '".$_POST['id']."'"; if(mysql_query($query)) { echo "Show updated."; }else{ die('<p>The show could not update because <b>' . mysql_error() . '</b>. The query was '."$query.".'</p>'); } } if($_GET['action'] == 'delete') { $query = "DELETE FROM shows WHERE id = '".$_GET['id']."'"; if(mysql_query($query)) { echo "Deletion successful."; }else{ die ('<p>Could not delete post because ' . mysql_error() . '. The query was '."$query.".'</p>'); } } ?>
-
Ahh well $image hasn't been set.. add the missing line <?php $image = $_FILES['uploadedfile']['name']; //<---Missing line $extension = explode(".", $image); $extension = $extension[count($extension)-1]; if(strtolower($extension) == "jpg") { ?>
-
if the upload.php is on the root and the uploads folder is also on the root try $upfile = dirname(__FILE__).'/uploads/'.$_FILES['userfile']['name'];
-
Try $upfile = '../uploads/'.$_FILES['userfile']['name'];
-
Okay the error is an SQL error from this line $get_colors_sql = "SELECT item_color FROM store_item_color WHERE item_id = '".$_GET["item_id"]."' ORDER BY item_color"; Now when you created the database table "store_item_color" you should have a field called "item_id" but it seam liek thats missing.. so you fix this problem you need to add that to the SQL database table
-
i would guess that the resize function resizes the images.. this is probably running out of memory or timeing out
-
<?php function libStripInputSlashes() { $input_arr = array(); foreach ($_REQUEST as $key => $input_arr) { $_REQUEST[$key] = htmlentities($input_arr); //this will do nothing $_REQUEST[$key] = mysql_real_escape_string($input_arr); } } ?> try this <?php function libStripInputSlashes() { $input_arr = array(); foreach ($_REQUEST as $key => $input_arr) { $_REQUEST[$key] = htmlentities($input_arr); $_REQUEST[$key] = mysql_real_escape_string($_REQUEST[$key]); //--OR //$input_arr= htmlentities($input_arr); //$_REQUEST[$key] = mysql_real_escape_string($input_arr); } } ?>
-
I assume by account details this includes parts that will be displayed in a userlist or something thats others may see, Now if something is missed by the error capture then it "could be" a risk.. it only takes a small security hole for the site to be exposed, and without knowing all the details it could be a security risk..
-
first of set_includepath uses local file access so no http:// stuff their try this include(dirname(__FILE__)."/header.php")
-
could be a security risk.. injecting javascript or iframes could be hell.. and defacing isn't nice.. as Orio Says:
-
[SOLVED] Pagination - Where am I going wrong?
MadTechie replied to mark110384's topic in PHP Coding Help
Yeah sorry i thought you was show 1 page then the next page (in singles) okay i would kinda need the full code as its very hard to say if your missing something ie the 2nd query is it being performed ? -
[SOLVED] Pagination - Where am I going wrong?
MadTechie replied to mark110384's topic in PHP Coding Help
HUmmm this line gets the thread $sql = "SELECT * FROM forum_topic WHERE thread_ID = '$thread_no' ORDER BY last_update DESC $limit"; but you only use $thread_no + 1 so if you delete a forum topic your get holes (the thread won't exist) i guess this is what your getting now.. may i suggect trying $sql = "SELECT * FROM forum_topic ORDER BY last_update DESC LIMIT $thread_no, 1 i removed you $limit as i don't know what it does ( i could guess ) EDIT: i sould point out that the example above will need tweaking but should give you the basic idea -
However: <?php $data = "agilgdyj lhcls tdmqjx qokkjf xbxan bwpgt cmucj zqbbrp bgac jwmlnx ufsxt photoshop maasp dpkka wpedb kczbb huqz jjbnf jcztpf hqvoi ccpau vljxa pyfjm mhhvb hyfkk rdqhk liwip aezeg ejyow jsuznw kuqsu syktt zctbq upijhvb lbdxn sewsgc tmdec ttjklz lrvht dqypb omqzpng decdj nskxjr mpcvx vccmath puddg laapcr uteqqo svzyo urgvub yvcro ihxjr ebvve rnngz zrudu irtlb cddzo yqxgy ngzro aktpk yahuc ndelz uzqtk olpar aqrty bnxpuygd vltxj citpj ngwso beysx bexpq testing "; $data = preg_replace('/\b((?:\w{0,4}|\w{16,}|[^\w]))\b/si', '', $data ); //will remove huqz & bgac, the rest is valid ?>
-
Why did you start a new thread ? Last thread = http://www.phpfreaks.com/forums/index.php/topic,221199.0.html thread before = http://www.phpfreaks.com/forums/index.php?topic=220819.0 personally i think your doing this all wrong.. either write a read that parse's the data correctly (will take a while) or use a DOM as Barand suggested
-
Try this here is an example <?php function cmp($a, $b) { return strcmp($a["cat_name"], $b["cat_name"]); } $data = array(); $data[] = Array ( "cat_parent_id" => 0, "cat_id" => 19, "cat_image" => "4754bded7e4b19603e571feeecb32fcc.jpg", "cat_name" => "Product A", "cat_description" => "Product description" ); $data[] = Array ( "cat_parent_id" => 19, "cat_id" => 31, "cat_image" => "", "cat_name" => "Product B", "cat_description" => "Adult" ); $data[] = Array ( "cat_parent_id" => 19, "cat_id" => 31, "cat_image" => "", "cat_name" => "Product R", "cat_description" => "Adult" ); $data[] = Array ( "cat_parent_id" => 19, "cat_id" => 31, "cat_image" => "", "cat_name" => "Product E", "cat_description" => "Adult" ); $data[] = Array ( "cat_parent_id" => 19, "cat_id" => 31, "cat_image" => "", "cat_name" => "Product A", "cat_description" => "Adult" ); $data[] = Array ( "cat_parent_id" => 19, "cat_id" => 31, "cat_image" => "", "cat_name" => "Product D", "cat_description" => "Adult" ); echo "Org List:<br><pre>"; foreach($data as $D) { echo $D['cat_name']."<br>"; } echo "<\pre>"; usort($data, "cmp"); echo "New List:<br><pre>"; foreach($data as $D) { echo $D['cat_name']."<br>"; } echo "<\pre>"; ?>
-
-
i have quick rewrite <?php ini_set('display_errors', 1); error_reporting(E_ALL); if ($_SERVER['REQUEST_METHOD']=="POST") { // we'll begin by assigning the To address and message subject $to="emailaddress"; $subject="E-mail with attachment"; $expected = array('fromname','fromemail'); $required = array('fromname','fromemail'); $missing = array(); $HasFile = false; // get the sender's name and email address // we'll just plug them a variable to be used later $from = stripslashes($_POST['fromname'])."<".stripslashes($_POST['fromemail']).">"; // generate a random string to be used as the boundary marker $mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x"; // store the file information to variables for easier access $HasFile = ($_FILES['filename']['size']>0); if($HasFile) { $tmp_name = $_FILES['filename']['tmp_name']; $type = $_FILES['filename']['type']; $name = $_FILES['filename']['name']; $size = $_FILES['filename']['size']; $fromname = $_POST['fromname']; // here we'll hard code a text message // again, in reality, you'll normally get this from the form submission $message = "Here is your file: $name\n"; }else{ $message = "No File attached\n"; } $message .= "From: $from\n\n"; // if the upload succeded, the file will exist //if (file_exists($tmp_name)){ //<--- REMOVE // check to make sure that it is an uploaded file and not a system file if($HasFile && is_uploaded_file($tmp_name)){ // open the file for a binary read $file = fopen($tmp_name,'rb'); // read the file content into a variable $data = fread($file,filesize($tmp_name)); // close the file fclose($file); // now we encode it and split it into acceptable length lines $data = chunk_split(base64_encode($data)); } if (empty($missing)) { // now we'll build the message headers $headers = "From: $from\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: multipart/mixed;\r\n" . " boundary=\"{$mime_boundary}\""; // next, we'll build the message body // note that we insert two dashes in front of the // MIME boundary when we use it $message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n"; // now we'll insert a boundary to indicate we're starting the attachment // we have to specify the content type, file name, and disposition as // an attachment, then add the file content and set another boundary to // indicate that the end of the file has been reached $message .= ($HasFile)?"--{$mime_boundary}\n" . "Content-Type: {$type};\n" . " name=\"{$name}\"\n" . //"Content-Disposition: attachment;\n" . //" filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n":""; define ("MAX_SIZE","1000"); if($HasFile) { $filename = stripslashes($name); $type = strtolower( file_extension( $filename)); if (($type != "jpg") && ($type != "jpeg") && ($type != "png") && ($type != "pdf") && ($type != "dwg") && ($type != "gif")) { echo 'Invalid file type! Only gif, jpg, pdf and DWG files are allowed to be uploaded</a>.'; echo $path_parts['extension'], "\n"; } if ($_FILES['filename']['size'] >= 1048576) { echo 'You have exceeded the size limit of 1Mb!'; echo ' Actual size of attachment: '.$_FILES['filename']['size']; } } } foreach ($_POST as $key => $value) { $temp = is_array($value) ? $value : trim($value); if (empty($temp) && in_array($key, $required)) { array_push($missing, $key); } elseif (in_array($key, $expected)) { ${$key} = $temp; } } if (isset($_POST['Submit'])) { if ($missing) { echo "Please Complete the missing items" ; echo '<p>The following required fields have not been filled in:</p>'; echo '<ul>'; foreach($missing as $item) { echo "<li>$item</li>"; } echo '</ul>'; } else { (mail($to, $subject, $message, $headers)) ; echo "Message was sent successfully."; } } //} //<----- REMOVE } function file_extension($filename) { $path_info = pathinfo($filename); return $path_info['extension']; } ?> <p>Send an e-mail with an attachment:</p> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data" name="form1"> <p>From name: <input type="text" name="fromname" <?php if (isset($missing)) { echo 'value="'.htmlentities($_POST['fromname']).'"';} ?> /> <p>From e-mail: <input type="text" name="fromemail" <?php if (isset($missing)) { echo 'value="'.htmlentities($_POST['fromemail']).'"';} ?> /> <p>File: <input type="file" name="filename" /> <p><input type="submit" name="Submit" value="Submit"> </form>
-
Extracting Gmail messages and importing them onto MySQL: Possible?
MadTechie replied to FForce2195's topic in PHP Coding Help
Well its a starting point i won't write the whole thing but that should give you a jump start.. as a side note.. i have a static IP at home and at the office but i hear theirs a problem with using gmails imap on a server with a dynamic external IP.. (just something to keep in mind) -
Welcome
-
You very welcome, can you click solved if that is the case