Jump to content

sblake161189

Members
  • Posts

    47
  • Joined

  • Last visited

    Never

Everything posted by sblake161189

  1. SOLVED!!! `photo` = '{$_POST['photo']}' it should be... `photo` = '{$_FILES['photo']['name']}' no errors and uploads thanks anyway!
  2. It doesnt like this bit I think `photo` = '{$_POST['photo']}' But its still not uploading an image to the images folder or inputing the file name into the photo column.
  3. Ooops! No, it didnt lol Ive added it now, but it says: Notice: Undefined index: photo in /home/theacidf/public_html/aidtofreedom/admin/edit.php on line 130 Line 130 = $sql= "UPDATE `ter` SET `Ter` = '{$_POST['Ter']}' , `BranchName` = '{$_POST['BranchName']}' , `BranchAddress` = '{$_POST['BranchAddress']}' , `BranchTel` = '{$_POST['BranchTel']}' , `BranchEmail` = '{$_POST['BranchEmail']}' , `BranchLink` = '{$_POST['BranchLink']}' , `Theme` = '{$_POST['Theme']}' , `LocalInfo` = '{$_POST['LocalInfo']}' , `BranchInfo` = '{$_POST['BranchInfo']}' , `photo` = '{$_POST['photo']}' WHERE `Ter` = '$ter' "; Plus it doesn't even upload the file name and extension to the photo column nomore... hmm Cheers, S
  4. Thanks guys, If I turn on error reporting I get... ------ Notice: Undefined index: photo in /home/theacidf/public_html/aidtofreedom/admin/edit.php on line 123 Notice: Undefined index: photo in /home/theacidf/public_html/aidtofreedom/admin/edit.php on line 125 Notice: Undefined index: photo in /home/theacidf/public_html/aidtofreedom/admin/edit.php on line 137 Notice: Undefined index: photo in /home/theacidf/public_html/aidtofreedom/admin/edit.php on line 140 Nothing changed. --- So it makes more sense to you, I have explained the different line no's as there is HTML that i didnt upload earlier. Line 123 = $target = $target . basename( $_FILES['photo']['name']); Line 125 = $photo =($_FILES['photo']['name']); Line 137 = if($_FILES['photo']['error']) { Line 140 = move_uploaded_file($_FILES['photo']['tmp_name'], $target); Cheers, S
  5. Hey Guys, I have a php script that update's franchise information using a mysql table. Note: Ter = Territory, ie. the territory that franchise covers. <?php include('config.php'); if (isset($_GET['Ter']) ) { $ter = (int) $_GET['Ter']; if (isset($_POST['submitted'])) { //Photo Upload //This is the directory where images will be saved $target = "images/"; $target = $target . basename( $_FILES['photo']['name']); //This gets all the other information from the form $photo =($_FILES['photo']['name']); //Pause Photo Upload foreach($_POST AS $key => $value) { $_POST[$key] = mysql_real_escape_string($value); } $sql= "UPDATE `ter` SET `Ter` = '{$_POST['Ter']}' , `BranchName` = '{$_POST['BranchName']}' , `BranchAddress` = '{$_POST['BranchAddress']}' , `BranchTel` = '{$_POST['BranchTel']}' , `BranchEmail` = '{$_POST['BranchEmail']}' , `BranchLink` = '{$_POST['BranchLink']}' , `Theme` = '{$_POST['Theme']}' , `LocalInfo` = '{$_POST['LocalInfo']}' , `BranchInfo` = '{$_POST['BranchInfo']}' , `photo` = '{$_POST['photo']}' WHERE `Ter` = '$ter' "; mysql_query($sql) or die(mysql_error()); //Unpause Photo Upload //Writes the photo to the server move_uploaded_file($_FILES['photo']['tmp_name'], $target); //End of Photo Upload echo (mysql_affected_rows()) ? "Edited Branch.<br />" : "Nothing changed. <br />"; } $row = mysql_fetch_array ( mysql_query("SELECT * FROM `ter` WHERE `Ter` = '$ter' ")); ?> In phpmyadmin I can see my table and it has the correct image name displayed in the photo column. So you would assume its worked. But when I look in the 'images/' location no image has been uploaded. So I think there is an error with the upload part but cant figure out whats wrong. Cheers, S
  6. Right OK, good point. But how do I adapt my existing edit.php form to upload the image into the location? And then upload the actual file location value into the database? Cheers, S
  7. Hi Guys! I already have a database with a table that stores information about different franchises for the company like franchise name, address, tel, email etc etc. This works beautiful so I can CRUD this data. However, now to be able to add the facility for each franchise to be able to upload their own image of the franchise itself and still be able to CRUD the data. I have looked on the internet and found many scripts using BLOB etc but I can get it to link in with my existing table. I'll show you the edit form that I have so far. (Pleas not Ter = territory, ie the territory that franchise covers. <?php include('config.php'); if (isset($_GET['Ter']) ) { $ter = (int) $_GET['Ter']; if (isset($_POST['submitted'])) { foreach($_POST AS $key => $value) { $_POST[$key] = mysql_real_escape_string($value); } $sql= "UPDATE `ter` SET `Ter` = '{$_POST['Ter']}' , `BranchName` = '{$_POST['BranchName']}' , `BranchAddress` = '{$_POST['BranchAddress']}' , `BranchTel` = '{$_POST['BranchTel']}' , `BranchEmail` = '{$_POST['BranchEmail']}' , `BranchLink` = '{$_POST['BranchLink']}' , `Theme` = '{$_POST['Theme']}' , `LocalInfo` = '{$_POST['LocalInfo']}' , `BranchInfo` = '{$_POST['BranchInfo']}' WHERE `Ter` = '$ter' "; mysql_query($sql) or die(mysql_error()); echo (mysql_affected_rows()) ? "Edited Branch.<br />" : "Nothing changed. <br />"; } $row = mysql_fetch_array ( mysql_query("SELECT * FROM `ter` WHERE `Ter` = '$ter' ")); ?> <form action='' method='POST'> <p><b>Territory:</b><br /><input name='Ter' type='text' value='<?= stripslashes($row['Ter']) ?>' size="3" readonly="readonly" /> <p><b>Branch Name:</b><br /><input name='BranchName' type='text' value='<?= stripslashes($row['BranchName']) ?>' size="50" /> <p><b>Address:</b><br /> <textarea name='BranchAddress' cols="40" rows="5"><?= stripslashes($row['BranchAddress']) ?></textarea> <p><b>Telephone:</b><br /><input name='BranchTel' type='text' value='<?= stripslashes($row['BranchTel']) ?>' size="15" /> <p><b>Email:</b><br /><input name='BranchEmail' type='text' value='<?= stripslashes($row['BranchEmail']) ?>' size="50" /> <p><b>Link:</b><br /><input name='BranchLink' type='text' value='<?= stripslashes($row['BranchLink']) ?>' size="50" /> <hr /> <p><b>Your Single Webpage Options</b> <p><b>Theme:</b><br /> <input name='Theme' type='text' value='<?= stripslashes($row['Theme']) ?>' size="1" /> <p><b>Local Information:</b><br /> <textarea name='LocalInfo' cols="85" rows="8" id="LocalInfo"><?= stripslashes($row['LocalInfo']) ?> </textarea> <p><b>Franchise Information:</b><br /> <textarea name='BranchInfo' cols="85" rows="8" id="BranchInfo"><?= stripslashes($row['BranchInfo']) ?> </textarea> <p><b>Photo:</b><br /> <label> <input type="file" name="photo" id="photo" /> </label> (Franchise Photo) <p><b>Downloads:</b><br /> <label> <input type="file" name="download1" id="download1" /> </label> (S/O Mandate) <p> <label> <input type="file" name="download2" id="download2" /> </label> (Other Download) <p> <label> <input type="file" name="download3" id="download3" /> </label> (Other Download) <p> <input type='submit' value='Save' /> <input type='hidden' value='1' name='submitted' /> </form> <? } ?> It is the 'photo' file above that I want to be able to upload the image with. Is this the right way to do it? Ignore the download1,2,3 bit. Cheers, S
  8. Hi Guys, I am trying to use a script that is available on the net to upload an image into a mysql using BLOB. However it wont upload it keep getting Warning: fread() [function.fread]: Length parameter must be greater than 0 in /home/theacidf/public_html/attendance/upload.php on line 17 Here is the code... <?php // Connect to database $errmsg = ""; if (! @mysql_connect("localhost","theacidf_admin","password")) { $errmsg = "Cannot connect to database"; } @mysql_select_db("theacidf_attendanc"); // Insert any new image into database if ($_REQUEST[completed] == 1) { move_uploaded_file($_FILES['imagefile']['tmp_name'],"latest.img"); $instr = fopen("latest.img","rb"); $image = addslashes(fread($instr,filesize("latest.img"))); if (strlen($image) < 149000) { mysql_query ("insert into pix (title, imgdata) values (\"". $_REQUEST[whatsit]. "\", \"". $image. "\")"); } else { $errmsg = "Too large!"; } } // Find out about latest image $gotten = @mysql_query("select * from pix order by pid desc limit 1"); if ($row = @mysql_fetch_assoc($gotten)) { $title = htmlspecialchars($row[title]); $bytes = $row[imgdata]; } else { $errmsg = "There is no image in the database yet"; $title = "no database image available"; // Put up a picture of our training centre $instr = fopen("../images/logo_png.png","rb"); $bytes = fread($instr,filesize("../images/logo_png.png")); } // If this is the image request, send out the image if ($_REQUEST[gim] == 1) { header("Content-type: image/jpeg"); print $bytes; exit (); } ?> <html><head> <title>Upload an image to a database</title> <body bgcolor=white><h2>Here's the latest picture</h2> <font color=red><?= $errmsg ?></font> <center><img src=?gim=1><br> <?= $title ?></center> <hr> <h2>Please upload a new picture and title</h2> <form enctype=multipart/form-data method=post> <input type=hidden name=MAX_FILE_SIZE value=150000> <input type=hidden name=completed value=1> Please choose an image to upload: <input type=file name=imagefile><br> Please enter the title of that picture: <input name=whatsit><br> then: <input type=submit></form><br> <hr> </body> </html> Why wont it run properly? Thanks in advance... S
  9. Hi Thanks, Didnt spot that so thanks... I have now changed it to $sql = "UPDATE `ter` SET `Ter` = '{$_POST['Ter']}' , '{$_POST['BranchName']}' , `BranchAddress` = '{$_POST['BranchAddress']}' , `BranchTel` = '{$_POST['BranchTel']}' , `BranchEmail` = '{$_POST['BranchEmail']}' , `BranchLink` = '{$_POST['BranchLink']}' WHERE `Ter` = '$ter' "; However it now says: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''Ter 1' , `BranchAddress` = 'fghgfh' , `BranchTel` = '' , `BranchEmail` = '' at line 1 Ta, S
  10. Hi, Sorry I probably didnt make myself clear enough... Ter is the effiectively the ID no of the branch. I want it to appear on the edit page but make it read-only so the user doesn't accidently edit it by mistake but it needs to be visable. However when I click submit after making ammendments to any of the other fields (which are not read only). I get the error: Duplicate entry '1' for key 1 because it is trying to change Ter to equal 1 but it wont let it because Ter is the primary key. Does that make more sense? Ta, S
  11. Hi Guys, I have a list of branches in a database table with the following collumns, Ter BranchName BranchAddress BranchTel BranchEmail BranchLink Ter = Terriotory ID However every time i update a branch using the edit.php code it always sets the Ter as 1 again! Rather than leaving it the same. The actual field is read-only to prevent that from happening. It then always comes up with the error Duplicate entry '1' for key 1 but thats because there is already a branch with Ter=1 include('config.php'); if (isset($_GET['Ter']) ) { $ter = (int) $_GET['Ter']; if (isset($_POST['submitted'])) { foreach($_POST AS $key => $value) { $_POST[$key] = mysql_real_escape_string($value); } $sql = "UPDATE `ter` SET `Ter` = `BranchName` = '{$_POST['BranchName']}' , `BranchAddress` = '{$_POST['BranchAddress']}' , `BranchTel` = '{$_POST['BranchTel']}' , `BranchEmail` = '{$_POST['BranchEmail']}' , `BranchLink` = '{$_POST['BranchLink']}' WHERE `Ter` = '$ter' "; mysql_query($sql) or die(mysql_error()); echo (mysql_affected_rows()) ? "Edited Branch.<br />" : "Nothing changed. <br />"; } $row = mysql_fetch_array ( mysql_query("SELECT * FROM `ter` WHERE `Ter` = '$ter' ")); <form action='' method='POST'> <p><b>Territory:</b><br /><input name='Ter' type='text' value='<?= stripslashes($row['Ter']) ?>' size="3" readonly="readonly" /> <p><b>Branch Name:</b><br /><input name='BranchName' type='text' value='<?= stripslashes($row['BranchName']) ?>' size="50" /> <p><b>Address:</b><br /> <textarea name="BranchAddress" cols="40" rows="5"><?= stripslashes($row['BranchAddress']) ?></textarea> <p><b>Telephone:</b><br /><input name='BranchTel' type='text' value='<?= stripslashes($row['BranchTel']) ?>' size="15" /> <p><b>Email:</b><br /><input name='BranchEmail' type='text' value='<?= stripslashes($row['BranchEmail']) ?>' size="50" /> <p><b>Link:</b><br /><input name='BranchLink' type='text' value='<?= stripslashes($row['BranchLink']) ?>' size="50" /> <p><input type='submit' value='Save' /><input type='hidden' value='1' name='submitted' /> </form> <? } ?> Any Ideas? Cheers, S
  12. As soon as I posted it I worked it out - always happens lol $mailheader .= "Cc: contact@theacidfrog.com" . "\r\n"; I missed the dot before the equals. Thanks anyways. lol
  13. Hi Guys, I have a PHP mail script and I have extracted a bits here... $email = mysql_real_escape_string($_POST['email']); $mailheader = "From: $email" . "\r\n"; // Always CC Email to HQ $mailheader = "Cc: contact@example.com" . "\r\n"; // Customers copy $mailheader .= "BCc: $email" . "\r\n"; $mailheader .= 'MIME-Version: 1.0' . "\r\n"; $mailheader .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; and another bit mail($to, $subject, $body, $mailheader); However when the email comes through it doesn't display the email address entered in the from field. Why? Ive done others and its worked, cant find out why.. Cheers, S
  14. Sorry forgot to say the other fields work, ie what it has got from the form <td bgcolor=#FFFFFF bordercolor=#666666 valign=top>' . strip_tags($_POST['comments']) . '</td> They show in the email...
  15. Hi Guys, I have a php mail script that calculates a branch to send it to dependant on the postcode which works fine as it goes to the right email and when I echo the script to show branch name it comes up with the correct branch name. However when you open the email I cannot get it to display the 'branch name'. It will display all the other bits of information that has been 'posted' from the form. But wont display the branch name form an sql database table. The code below proves that it finds the branch name. while($row = mysql_fetch_array( $result )) { $ter = $row['Ter']; $branchemail = $row['BranchEmail']; $branchname = $row['BranchName']; } This is the PHP Mail in HTML part below <td bgcolor=#FFFFFF bordercolor=#666666 valign=top>' . ( $row['BranchName']) . '</td> But when the email comes through the branch name is always blank. However on this page I can get it to echo the branch name and it displays the branch name and also emails to the branch email address. Any ideas why it doesn't work. Cheers, S
  16. Thanks guys thats a great help - works beautifully
  17. Hi Guys, I don't know how to do this but basically I want the value of $postcode3 to equal the value of $postcodep1 aswell as $postcodep2 like this... else {$postcode3 = $postcodep1 $postcodep2;} That doesn't work... Say $postcodep1 = LS14 $postcodep2 = 2AB Then $postcode3 = LS14 2AB How do I write this in the above php code?! Thanks, S
  18. Sorted! Its not... // The address of the branch to send to $to = $branchemail; $to .= $email; } delete the $to .=$email I changed the mailheaders to: $mailheader = "From: $email" . "\r\n"; // Always CC Email to HQ $mailheader = "Cc: hq@example.com" . "\r\n"; // Customers copy $mailheader .= "BCc: $email" . "\r\n"; then mail($to, $subject, $body, $mailheader); Sorted! Thanks!
  19. The booking_sent.php page then outputs (with no space): branch@example.comcustomer@something.com Somehow I need to seperate those with a ; to put it in the correct mail format I am assuming? This is using this code further up: // The address of the branch to send to $to = $branchemail; $to .= $email; }
  20. Hi Guys, Basically, I have a long php script to calculate the nearest branch dependant on there postcode hence why $to = $branchemail at the end. It will send it to HQ if anything goes wrong as a safeguard. Here is a small piece of my php code: if (strlen($branchemail) == 0){ // Default Address if anything goes wrong $to = "hq@example.com"; } else { // The address of the branch to send to $to = $branchemail; } What I can't seem to do is also send the customer filling in the php form a copy of the email sent. The variable for the customers email is $email I have tried this and it doesn't seem to work either... // The address of the branch to send to $to = $branchemail; $to .= $email; } At the bottom of the script, there is this code to physically send the email. This also always sends a copy to hq aswell. echo "Thank you for contacting us, we have received your message and we aim to respond your very shortly."; mail($to, $subject, $body, $mailheader); // THIS LINE TO CC Email mail("hq@example.com", $subject, $body, $mailheader); } else { echo "There has been an error code 1. Please try again."; So basically I just can't get it to send a copy to the customer filling it in ($email) Any idea's because my mind has gone blank. Cheers, S
×
×
  • 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.