Jump to content

sblake161189

Members
  • Posts

    47
  • Joined

  • Last visited

    Never

Everything posted by sblake161189

  1. Hi Guys, I am normally switched on when it comes to PHP mysql_query's but for some reason I cannot work this one out. Its probably something daft! I have a SELECT * query's which then displays results in the table. But for some reason it isnt showing every result (i.e. some properties are missing). I have worked out they are the properties where there is no customer, orderdetail or payment linked to it. I would like it to show ALL results regardless of wether a customer, order or payment is attached it. Here is my code: <?php // Find All Properties $resulta = mysql_query("SELECT * FROM yea_properties ORDER BY PROPERTY_ID DESC"); if(mysql_num_rows($resulta)==0) { echo "No properties in database."; } else { ?> <table width="990" border="0"> <tr> <td><strong>Property ID</strong></td> <td><strong>Address</strong></td> <td><strong>Created</strong></td> <td><strong>Customer</strong></td> <td><strong>Order</strong></td> </tr> <?php while($property=mysql_fetch_array($resulta)){ $propertyID = $property['PROPERTY_ID']; // Find Details of Prop/Customer Link $resultb = mysql_query("SELECT * FROM yea_link_prop_cust WHERE PROPID = '$propertyID'"); $link = mysql_fetch_array($resultb); $userID = $link['USERID']; // Find Details of Customer $resultc = mysql_query("SELECT * FROM yea_customers WHERE USERID = '$userID'"); while($customer=mysql_fetch_array($resultc)){ // Find Details of Latest Order with Property $resultd = mysql_query("SELECT * FROM yea_orderdetails WHERE DetailPropertyID = '$propertyID' ORDER BY DetailOrderID DESC Limit 0,1"); while($order=mysql_fetch_array($resultd)){ $orderID = $order['DetailOrderID']; // Find Details of Payment $resulte = mysql_query("SELECT * FROM yea_payments WHERE orderID = '$orderID'"); $payment = mysql_fetch_array($resulte); $paymentID = $payment['paymentID']; ?> <tr> <td><a href="view-property.php?propertyID=<?php echo $propertyID; ?>">View Property #<?php echo $propertyID; ?></a></td> <td><?php echo $property['ADDRESS_1']; ?> <?php echo $property['ADDRESS_2']; ?>, <?php echo $property['ADDRESS_3']; ?>, <?php echo $property['TOWN']; ?>, <?php echo $property['POSTCODE1']; ?> <?php echo $property['POSTCODE2']; ?></td> <td><?php echo $property['CREATE_DATE']; ?></td> <td><a href="view-customer.php?userID=<?php echo $customer['USERID']; ?>">Customer #<?php echo $customer['USERID']; ?> (<?php echo $customer['FIRST_NAME']; ?> <?php echo $customer['LAST_NAME']; ?>)</a></td> <td><a href="view-order.php?orderID=<?php echo $orderID; ?>&paymentID=<?php echo $paymentID; ?>">View Order #<?php echo $orderID; ?></a></td> </tr> <?php }}}} ?> </table> Any help would be much appreciated
  2. Just incase any of you are confused... The reason it didnt like <div id="description"> was because when it was looking for getElementByID('description'); it was finding the META 'description' tag rather than my DIV. I have changed it in the above code to <div id="blogdescription"> as this was then different to the META. Changing that and the above code made it work
  3. Hi Guys, Thanks for all your help... I have found the following works... it might not be the tidiest solution, but it does the job... <?php $url="http://www.example.com?id=1"; $html = file_get_contents($url); $doc = new DOMDocument(); @$doc->loadHTML($html); $doc = $doc->getElementById('blogdescription'); $images = $doc->getElementsByTagName('img'); foreach ($images as $image) { echo $image->getAttribute('src')."<br/>"; } ?> Cheers
  4. Hi there, Nope its the only div with that ID as per W3C validations... Here is the code within the page its looking at... <div id="description"> <?php echo($blog['description']); ?> </div> Although its a foreach it still should find just that one instance of the <div id="description"> in there. Thanks for your help :-)
  5. Thanks for your reply... I have tried that but unless I am being stupid it doesnt find the <div id="description"> <?php $url="http://www.example.com?id=1"; $html = file_get_contents($url); $doc = new DOMDocument(); @$doc->loadHTML($html); $divs = $doc->getElementByID('description'); foreach ($divs as $div) { echo "Found the description div <br />"; } ?> It finds nothing and appears blank...
  6. Hi All, I have the following code to find all the image src's for all the images within a current page. However I would like to adapt it so it only looks within the <div id="description">. Any ideas on how to do that? I have tried Googling with not much look. <?php $url="http://www.example.com?id=1"; $html = file_get_contents($url); $doc = new DOMDocument(); @$doc->loadHTML($html); $images = $doc->getElementsByTagName('img'); foreach ($images as $image) { echo $image->getAttribute('src')."<br/>"; } ?> Cheers Guys!
  7. Hi All, I have a form which POSTs data through to PHP, it then places this on a HTML mail and then emails the company. I then have two attachment fields on the form, one for their CV and the other for some sort of ID. The attachments appear on the HTML email but when you try and open them or download and open them they come up with an error as though they are corrupt. However the odd thing is if I open it on my iPhone the attachments work perfect. Its not just my PC at fault as it doesnt work on many computers/OS's. The actual PHP attachment code is below: <?php $unid = md5(time()); for($i=0;$i<count($_FILES["fileAttach"]["name"]); $i++) { if($_FILES["fileAttach"]["name"][$i] != "") { $filename = $_FILES["fileAttach"]["name"][$i]; $attachment = chunk_split(base64_encode(file_get_contents($_FILES["fileAttach"]["tmp_name"][$i]))); $mailheader .= "--" . $unid . "\n"; $mailheader .= "Content-Type: multipart/mixed; name=" . $filename . "\n"; $mailheader .= "Content-Transfer-Encoding: base64"."\n"; $mailheader .= "Content-Disposition: attachment; filename=" . $filename . "\n"; $mailheader .= $attachment; } } ?> What am I doing wrong. More code can be provided if needed. Cheers in advance!
  8. Hi Guys, Please can someone shred some light on what im doing wrong. Upon form submission it takes you to the success page. It then grabs the data, emails it through to the owner as a HTML email and then attaches 2 file attachments. The issue I am having is the attachments appear BUT they will not open. Its as though the files are corrupt. Part of the form is as follows: CV: <input name="fileAttach[]" type="file" class="field" /> ID: <input name="fileAttach[]" type="file" class="field" /> The PHP is as follows: (please ignore most of the HTML body content from the email, the attachment bit is at the bottom) <?php // Grab Data from Form if(isset($_POST['submit'])) { // Personal Information $surname = mysql_real_escape_string($_POST['surname']); $firstname = mysql_real_escape_string($_POST['firstname']); $telephone = mysql_real_escape_string($_POST['telephone']); $mobile = mysql_real_escape_string($_POST['mobile']); $email = mysql_real_escape_string($_POST['email']); $address = mysql_real_escape_string($_POST['address']); $postcodep1 = mysql_real_escape_string($_POST['postcodep1']); $postcodep2 = mysql_real_escape_string($_POST['postcodep2']); $dob_dd = mysql_real_escape_string($_POST['dob_dd']); $dob_mm = mysql_real_escape_string($_POST['dob_mm']); $dob_yyyy = mysql_real_escape_string($_POST['dob_yyyy']); // Next of Kin $nextkinname = mysql_real_escape_string($_POST['nextkinname']); $nextkintel = mysql_real_escape_string($_POST['nextkintel']); // Availability $days_mon = mysql_real_escape_string($_POST['days_mon']); $days_tue = mysql_real_escape_string($_POST['days_tue']); $days_wed = mysql_real_escape_string($_POST['days_wed']); $days_thu = mysql_real_escape_string($_POST['days_thu']); $days_fri = mysql_real_escape_string($_POST['days_fri']); $days_sat = mysql_real_escape_string($_POST['days_sat']); $days_sun = mysql_real_escape_string($_POST['days_sun']); $availability_am = mysql_real_escape_string($_POST['availability_am']); $availability_pm = mysql_real_escape_string($_POST['availability_pm']); $availability_allday = mysql_real_escape_string($_POST['availability_allday']); $availability_requirements = mysql_real_escape_string($_POST['availability_requirements']); // Experience $experience = mysql_real_escape_string($_POST['experience']); // Rates $rate = mysql_real_escape_string($_POST['rate']); $rate_specific = mysql_real_escape_string($_POST['rate_specific']); // Employer Ref $employrefname = mysql_real_escape_string($_POST['employrefname']); $employrefcomp = mysql_real_escape_string($_POST['employrefcomp']); $employreftel = mysql_real_escape_string($_POST['employreftel']); $employrefadd = mysql_real_escape_string($_POST['employrefadd']); // Personal Ref $persrefname = mysql_real_escape_string($_POST['persrefname']); $persreftel = mysql_real_escape_string($_POST['persreftel']); $persrefadd = mysql_real_escape_string($_POST['persrefadd']); // Extra Information $allergy = mysql_real_escape_string($_POST['allergy']); $allergy_details = mysql_real_escape_string($_POST['allergy_details']); $drive = mysql_real_escape_string($_POST['drive']); $car = mysql_real_escape_string($_POST['car']); $criminal = mysql_real_escape_string($_POST['criminal']); $criminal_details = mysql_real_escape_string($_POST['criminal_details']); $howlongworkuk = mysql_real_escape_string($_POST['howlongworkuk']); $police_check = mysql_real_escape_string($_POST['police_check']); $right2work = mysql_real_escape_string($_POST['right2work']); $right2workna = mysql_real_escape_string($_POST['right2workna']); //*** Uniqid Session ***// $strSid = md5(uniqid(time())); // Email Options $subject = "XXX Job Application"; $to = "test@test.com"; $mailheader = ""; $mailheader .= "From: $email" . "\r\n"; // Applicants copy $mailheader .= "BCc: $email" . "\r\n"; $mailheader .= "MIME-Version: 1.0\n"; $mailheader .= "Content-Type: multipart/mixed; boundary=\"".$strSid."\"\n\n"; $mailheader .= "This is a multi-part message in MIME format.\n"; $mailheader .= "--".$strSid."\n"; $mailheader .= "Content-type: text/html; charset=utf-8\n"; $mailheader .= "Content-Transfer-Encoding: 7bit\n\n"; // Message Content $body = '<html><head><style media="all" type="text/css">.table{background-color:#d8f0f8; cellpadding:3; cellspacing:10; border:10; width:625; bordercolor:#d8f0f8; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; padding:5;} .field{margin-left: 5px; margin-right:5px; padding:8px;}</style></head><body>'; $body .= '<table class="table"> <tr> <td colspan="5"> <h2 style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 1.3em; margin: 0; text-transform: uppercase; padding-bottom: 10px;">Cleaner Details</h2> </td></tr> <tr> <td></td> <td width="50%" >NAME:</td> <td></td> <td width="50%" >DATE OF BIRTH:</td> <td></td> </tr> <tr class="input"> <td></td> <td bgcolor="#FFFFFF" bordercolor="#666666" class="field">' . strip_tags($_POST['firstname']) . ' ' . strip_tags($_POST['surname']) . '</td> <td></td> <td bgcolor="#FFFFFF" bordercolor="#666666" class="field">' . strip_tags($_POST['dob_dd']) . '/' . strip_tags($_POST['dob_mm']) . '/' . strip_tags($_POST['dob_yyyy']) . '</td> <td></td> </tr> <tr class="field"> <td></td> <td>ADDRESS:</td> <td></td> <td>TELEPHONE:</td> <td></td> </tr> <tr class="input"> <td></td> <td rowspan="3" bgcolor="#FFFFFF" bordercolor="#666666" class="field">' . strip_tags($_POST['address']) . ' ' . strip_tags($_POST['postcodep1']) . ' ' . strip_tags($_POST['postcodep2']) . '</td> <td></td> <td bgcolor="#FFFFFF" bordercolor="#666666" class="field">' . strip_tags($_POST['telephone']) . '</td> <td></td> </tr> <tr class="input"> <td></td> <td></td> <td>MOBILE:</td> <td></td> </tr> <tr class="input"> <td></td> <td></td> <td bgcolor="#FFFFFF" bordercolor="#666666" class="field">' . strip_tags($_POST['mobile']) . '</td> <td></td> </tr> <tr > <td></td> <td colspan=3>EMAIL:</td> <td></td> </tr> <tr > <td></td> <td colspan=3 bgcolor=#FFFFFF bordercolor=#666666 class="field">' . strip_tags($_POST['email']) . '</td> <td></td> </tr> <tr> <td colspan=5><h2 style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 1.3em; margin: 0; text-transform: uppercase; padding-bottom: 5px; padding-top: 10px;">EMERGENCY CONTACT INFORMATION</h2></td> </tr> <tr> <td colspan=5 class="field"><hr size=1 /></td> </tr> <tr> <td></td> <td >NAME:</td> <td></td> <td >TELEPHONE:</td> <td></td> </tr> <tr > <td></td> <td bgcolor=#FFFFFF bordercolor=#666666 class="field">' . strip_tags($_POST['nextkinname']) . '</td> <td></td> <td bgcolor=#FFFFFF bordercolor=#666666 class="field">' . strip_tags($_POST['nextkintel']) . '</td> <td></td> </tr> <tr> <td colspan=5><h2 style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 1.3em; margin: 0; text-transform: uppercase; padding-bottom: 5px; padding-top: 10px;">EXPERIENCE</h2></td> </tr> <tr> <td colspan=5><hr size=1 /></td> </tr> <tr> <td></td> <td colspan="3" bgcolor=#FFFFFF bordercolor=#666666 class="field">' . strip_tags($_POST['experience']) . '</td> <td></td> </tr> <tr> <td></td> <td>CLEANERS RATE:</td> <td></td> </tr> <tr> <td></td> <td bgcolor=#FFFFFF bordercolor=#666666 class="field">' . strip_tags($_POST['rate']) . ' ' . strip_tags($_POST['rate_specific']) . '</td> <td></td> </tr> <tr> <td colspan=5><hr size=1 /></td> </tr> <tr> <td colspan=5><h2 style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 1.3em; margin: 0; text-transform: uppercase; padding-bottom: 5px; padding-top: 10px;">AVAILABILITY</h2></td> </tr> <tr> <td></td> <td >WEEKDAYS:</td> <td></td> <td >SPECIFIC REQUIREMENTS:</td> <td></td> </tr> <tr> <td></td> <td bgcolor=#FFFFFF bordercolor=#666666 valign=top >Monday: ' . strip_tags($_POST['days_mon']) . '<br /> Tuesday: ' . strip_tags($_POST['days_tue']) . '<br /> Wednesday: ' . strip_tags($_POST['days_wed']) . '<br /> Thursday: ' . strip_tags($_POST['days_thu']) . '<br /> Friday: ' . strip_tags($_POST['days_fri']) . '<br /> Saturday: ' . strip_tags($_POST['days_sat']) . '<br /> Sunday: ' . strip_tags($_POST['days_sun']) . '<br /> <br /> I am available on the above days in the:<br /> <br /> Morning: ' . strip_tags($_POST['availability_am']) . '<br /> Afternoon: ' . strip_tags($_POST['availability_pm']) . '<br /> All Day: ' . strip_tags($_POST['availability_allday']) . '<br /> </td> <td></td> <td bgcolor=#FFFFFF bordercolor=#666666 valign=top>' . strip_tags($_POST['availability_requirements']) . '</td> <td></td> </tr> <tr> <td colspan=5><hr size=1 /></td> </tr> <tr> <td colspan=5><h2 style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 1.3em; margin: 0; text-transform: uppercase; padding-bottom: 5px; padding-top: 10px;">REFERENCES</h2></td> </tr> <tr> <td></td> <td><b>EMPLOYER REFERENCE</b></td> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td>NAME:</td> <td></td> <td>COMPANY:</td> <td></td> </tr> <tr> <td></td> <td bgcolor=#FFFFFF bordercolor=#666666 valign=top>' . strip_tags($_POST['employrefname']) . '</td> <td></td> <td bgcolor=#FFFFFF bordercolor=#666666 valign=top>' . strip_tags($_POST['employrefcomp']) . '</td> <td></td> </tr> <tr> <td></td> <td>ADDRESS:</td> <td></td> <td>TELEPHONE:</td> <td></td> </tr> <tr> <td></td> <td bgcolor=#FFFFFF bordercolor=#666666 valign=top>' . strip_tags($_POST['employrefadd']) . '</td> <td></td> <td bgcolor=#FFFFFF bordercolor=#666666 valign=top>' . strip_tags($_POST['employreftel']) . '</td> <td></td> </tr> <tr> <td></td> <td><b>PERSONAL REFERENCE</b></td> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td>NAME:</td> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td bgcolor=#FFFFFF bordercolor=#666666 valign=top>' . strip_tags($_POST['persrefname']) . '</td> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td>ADDRESS:</td> <td></td> <td>TELEPHONE:</td> <td></td> </tr> <tr> <td></td> <td bgcolor=#FFFFFF bordercolor=#666666 valign=top>' . strip_tags($_POST['persrefadd']) . '</td> <td></td> <td bgcolor=#FFFFFF bordercolor=#666666 valign=top>' . strip_tags($_POST['persreftel']) . '</td> <td></td> </tr> <tr> <td colspan=5><hr size=1 /></td> </tr> <tr> <td colspan=5><h2 style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 1.3em; margin: 0; text-transform: uppercase; padding-bottom: 5px; padding-top: 10px;">OTHER INFORMATION</h2></td> <tr> <td></td> <td bgcolor=#FFFFFF bordercolor=#666666 valign=top> Police Check Complete: ' . strip_tags($_POST['police_check']) . '<br /> Criminal Convictions: ' . strip_tags($_POST['criminal']) . ' ' . strip_tags($_POST['criminal_details']) . '<br /> Right to Work: ' . strip_tags($_POST['right2work']) . '<br /> Not Applicable: ' . strip_tags($_POST['right2workna']) . '<br /> Worked in the UK: ' . strip_tags($_POST['howlongworkuk']) . '<br /> </td> <td></td> <td bgcolor=#FFFFFF bordercolor=#666666 valign=top> Allergies: ' . strip_tags($_POST['allergy']) . ' ' . strip_tags($_POST['allergy_details']) . '<br /> Drive? ' . strip_tags($_POST['drive']) . '<br /> Car? ' . strip_tags($_POST['car']) . ' </td> <td></td> </tr> <tr> <td></td> <td>SIGNED BY CLEANER:</td> <td></td> <td>DATE:</td> <td></td> </tr> <tr> <td></td> <td bgcolor=#FFFFFF bordercolor=#666666 valign=top> X </td> <td></td> <td bgcolor=#FFFFFF bordercolor=#666666 valign=top> </td> <td></td> </tr> </tr> <tr><td></td><td></td><td></td></tr> </table>'; $body .= "</body></html>"; // Upload Attachments for($i=0;$i<count($_FILES["fileAttach"]["name"]);$i++) { if($_FILES["fileAttach"]["name"][$i] != "") { $mailheader .= $body ."\n\n"; $FilesName = $_FILES["fileAttach"]["name"][$i]; $Content = chunk_split(base64_encode(file_get_contents($_FILES["fileAttach"]["tmp_name"][$i]))); $mailheader .= "--".$strSid."\n"; $mailheader .= "Content-Type: application/octet-stream; name=\"".$FilesName."\"\n"; $mailheader .= "Content-Transfer-Encoding: base64\n"; $mailheader .= "Content-Disposition: attachment; filename=\"".$FilesName."\"\n\n"; $mailheader .= $Content."\n\n"; } } // End of Email Content > Display Message echo "Thank you. Your application was submitted to us successly. We review all applications carefully and we may contact you shortly."; // Attempt to Send Email mail($to, $subject, $body, $mailheader); } else { echo "Application Failed. Unfortunatley, there was a problem with your application and it was not submitted. Please try again later or alternativley please contact us."; } ?> Any help would be much appreicated. Thanks guys! Sam
  9. Thanks guys - it all works B-E-A-UTIFULLY!
  10. Hi All, I am using an eBay API to display some results in a table on a PHP page. I am currently using the following code to display 'Time Left' until the auction ends. <?php echo $item->sellingStatus->timeLeft ?> And this outputs something similar to "P0DT0H4M14S" ie. 0 Days, 0 Hours, 4 Mins, 14 Seconds. Is there any easy way to make this look more normal like 4m, 4s - using substr() doesnt work becuase it depends on whether the values are single or double figure values... Any ideas im stuck... ive read somewhere its ISO-8601... Cheers
  11. Webstyles that works mint, thank you very much!
  12. Hi All, I think im having one of those days when you want to rip your hair out... My problem is... I want to produce the total number of results in my table that match a particular query... that query in English is... calculate the total number of records where field category = C Category... When im in phpMyadmin and perform a search it finds all the records that have the value of C Category in the category field. If I then choose 'show php code' i get: $sql = "SELECT * FROM `staff` WHERE `category` = \'C Category\' LIMIT 0, 30 "; In my php document, i use... <?php include ('config.php'); $sql="SELECT * FROM `staff` WHERE `category` = \'C Category\' LIMIT 0, 30 "; $result=mysql_query($sql); $num_rows = mysql_num_rows($result); echo $num_rows; ?> But I get a blank page... what am I doing wrong? Cheers
  13. Hi Guys, I have a HTML form which posts to a PHP mail script page. This data then emails to the company email address. I have two file attachments on my form: CV and Photo ID How do I integrate my php mail script to upload and then email these TWO files as TWO attachements on the email? $fileatt_cv $fileatt_id I have tried a few methods that I found on Google but they dont work <?php // Grab Data from Form if(isset($_POST['submit'])) { // Personal Information $surname = mysql_real_escape_string($_POST['surname']); $firstname = mysql_real_escape_string($_POST['firstname']); $telephone = mysql_real_escape_string($_POST['telephone']); $mobile = mysql_real_escape_string($_POST['mobile']); $email = mysql_real_escape_string($_POST['email']); $address = mysql_real_escape_string($_POST['address']); $postcodep1 = mysql_real_escape_string($_POST['postcodep1']); $postcodep2 = mysql_real_escape_string($_POST['postcodep2']); $dob_dd = mysql_real_escape_string($_POST['dob_dd']); $dob_mm = mysql_real_escape_string($_POST['dob_mm']); $dob_yyyy = mysql_real_escape_string($_POST['dob_yyyy']); // Next of Kin $nextkinname = mysql_real_escape_string($_POST['nextkinname']); $nextkintel = mysql_real_escape_string($_POST['nextkintel']); // Availability $days_mon = mysql_real_escape_string($_POST['days_mon']); $days_tue = mysql_real_escape_string($_POST['days_tue']); $days_wed = mysql_real_escape_string($_POST['days_wed']); $days_thu = mysql_real_escape_string($_POST['days_thu']); $days_fri = mysql_real_escape_string($_POST['days_fri']); $days_sat = mysql_real_escape_string($_POST['days_sat']); $days_sun = mysql_real_escape_string($_POST['days_sun']); $availability_am = mysql_real_escape_string($_POST['availability_am']); $availability_pm = mysql_real_escape_string($_POST['availability_pm']); $availability_allday = mysql_real_escape_string($_POST['availability_allday']); $availability_requirements = mysql_real_escape_string($_POST['availability_requirements']); // Experience $experience = mysql_real_escape_string($_POST['experience']); // File Attachments $fileatt_cv = mysql_real_escape_string($_POST['fileatt_cv']); $fileatt_id = mysql_real_escape_string($_POST['fileatt_id']); // Rates $rate = mysql_real_escape_string($_POST['rate']); $rate_specific = mysql_real_escape_string($_POST['rate_specific']); // Employer Ref $employrefname = mysql_real_escape_string($_POST['employrefname']); $employrefcomp = mysql_real_escape_string($_POST['employrefcomp']); $employreftel = mysql_real_escape_string($_POST['employreftel']); $employrefadd = mysql_real_escape_string($_POST['employrefadd']); // Personal Ref $persrefname = mysql_real_escape_string($_POST['persrefname']); $persreftel = mysql_real_escape_string($_POST['persreftel']); $persrefadd = mysql_real_escape_string($_POST['persrefadd']); // Extra Information $allergy = mysql_real_escape_string($_POST['allergy']); $allergy_details = mysql_real_escape_string($_POST['allergy_details']); $drive = mysql_real_escape_string($_POST['drive']); $car = mysql_real_escape_string($_POST['car']); $criminal = mysql_real_escape_string($_POST['criminal']); $criminal_details = mysql_real_escape_string($_POST['criminal_details']); $howlongworkuk = mysql_real_escape_string($_POST['howlongworkuk']); $police_check = mysql_real_escape_string($_POST['police_check']); $right2work = mysql_real_escape_string($_POST['right2work']); $right2workna = mysql_real_escape_string($_POST['right2workna']); // Email Options $subject = "Test Company - Job Application"; $to = "test@test.com"; $mailheader = "From: $email" . "\r\n"; $mailheader .= 'MIME-Version: 1.0' . "\r\n"; $mailheader .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Applicants copy $mailheader .= "BCc: $email" . "\r\n"; // Message Content $body .= 'Message'; // End of Email Content > Display Message echo "Thank you. Your application was submitted to us successly. We review all applications carefully and we may contact you shortly."; // Attempt to Send Email mail($to, $subject, $body, $mailheader); } else { echo "Application Failed. Unfortunatley, there was a problem with your application and it was not submitted. Please try again later or alternativley please contact us."; } ?> Thanks in advanced.
  14. Sorted Options +FollowSymLinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)$ /sites/0.php?BranchName=$1 [QSA] Yet again, thanks again for your help!
  15. I have also just tried RewriteRule ^(.*)$ /sites/0.php?BranchName=$1 [L] and I got a 404 error for .com/leeds hmmmm
  16. Cheers fella, That kind of on the right lines of what I'm looking far so thanks RewriteRule ^BranchName/(.*)$ /sites/0.php?BranchName=$1 [L] But that means I have to type .com/BranchName/leeds for it come up Any way of modifying it so its just .com/leeds Cheers I have also just tried RewriteRule ^(.*)$ /sites/0.php?BranchName=$1 [L] and I got a 404 error for .com/leeds hmmmm
  17. Ignore my last post... I have now changed it so it works off BranchName <?php include('../admin/config.php'); if (isset($_GET['BranchName'])) { $ter = (int) $_GET['Ter']; $branchname = $_GET['BranchName']; $row = mysql_fetch_array ( mysql_query("SELECT * FROM `ter` WHERE `BranchName` = '$branchname' ")); ?> So any clues on how to modify the .htaccess so the user can type .com/leeds and it takes you to .com/sites/0.php?BranchName=Leeds but remains as .com/leeds in the address bar? Thanks, Sam
  18. Thanks for that My PHP script at the top of my page (0.php) is as follows: <?php include('../admin/config.php'); if (isset($_GET['Ter']) ) { $ter = (int) $_GET['Ter']; $row = mysql_fetch_array ( mysql_query("SELECT * FROM `ter` WHERE `Ter` = '$ter' ")); ?> Can I say in PHP: SELECT * FROM `ter` WHERE `Ter` = '$ter' or `BranchName` = '$branchname' Does that make sense? Cheers
  19. Hi Guys, I no its only a partial PHP question but its still related to PHP... I have a URL .com/sites/0.php?Ter=144 and it takes you to a page and loads details with the id (ter) equalling 144 and displays all of 144's information... normal PHP stuff However I want to be able to put a Rewrite rule using a .htaccess (unless there is a better method!?) to get search engine frienly results. However I dont want the user to type .com/144 to bring up the Leeds branch. I want them to type .com/leeds and it bring up 144 (Leeds Branch). BranchName is the field I use for the branch name in my MySQL table. Is this possible? Also when I enter .com/sites/0.php?BranchName=Leeds that doesnt work either... Cheers, Sam
  20. I like the PHP one... Do I just place that after $sql= "UPDATE `ter` SET ? so it looks like this... $sql= "UPDATE `ter` SET "`BranchName` = " . ($_POST['BranchName'] ? "'{$_POST['BranchName']}'" : "`BranchName`") ...etc Cheers, S
  21. Hey, Yeah I like your idea... but how to do I link it in with the UPDATE command... 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` = '$timestamp_photo{$_FILES['photo']['name']}' , `download1` = '$timestamp_download1{$_FILES['download1']['name']}' , `download1name` = '{$_POST['download1name']}' , `download2` = '$timestamp_download2{$_FILES['download2']['name']}' , `download2name` = '{$_POST['download2name']}' , `download3` = '$timestamp_download3{$_FILES['download3']['name']}' , `download3name` = '{$_POST['download3name']}' WHERE `Ter` = '$ter' "; Cheers, S
  22. When I 'upload' the first file lets say a photo in the photo field it uploads absolutley fine and shows in the table and also on the page. However, at a later time, if i update the address for example and click submit. Then the file name+extension of the photo in the mysql table is removed and I'm just left with a new timestamp. But the address has been updated. This is fine for any normal text fields. But a pain with files on my form. Cheers
  23. Hi Guys, I want my UPDATE function from the code below to only update those fields that are NOT empty - if they are empty on submit then do not update or change any values from that field. I know that sounds odd, but with my file fields, when I submit to change something else at a later date it will overwrite the photo, download1,2 & 3 values and as a result I loose my files from the mysql table. Cheers, S <?php include('config.php'); if (isset($_GET['Ter']) ) { $ter = (int) $_GET['Ter']; if (isset($_POST['submitted'])) { //Photo & Document Upload Upload $timestamp_photo = time(); $timestamp_download1 = time(); $timestamp_download2 = time(); $timestamp_download3 = time(); //This is the directory where the files will be saved //Photos $photo_target = "images/"; $photo_target = $photo_target .$timestamp_photo. basename( $_FILES['photo']['name']); //Documents $download_target = "documents/"; $download_target1 = $download_target .$timestamp_download1. basename( $_FILES['download1']['name']); $download_target2 = $download_target .$timestamp_download2. basename( $_FILES['download2']['name']); $download_target3 = $download_target .$timestamp_download3. basename( $_FILES['download3']['name']); //This gets all the other information from the form $photo = ($_FILES['photo']['name']); $download1 = ($_FILES['download1']['name']); $download2 = ($_FILES['download2']['name']); $download3 = ($_FILES['download3']['name']); //Pause Photo/Document 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` = '$timestamp_photo{$_FILES['photo']['name']}' , `download1` = '$timestamp_download1{$_FILES['download1']['name']}' , `download1name` = '{$_POST['download1name']}' , `download2` = '$timestamp_download2{$_FILES['download2']['name']}' , `download2name` = '{$_POST['download2name']}' , `download3` = '$timestamp_download3{$_FILES['download3']['name']}' , `download3name` = '{$_POST['download3name']}' WHERE `Ter` = '$ter' "; mysql_query($sql) or die(mysql_error()); //Unpause Photo/Document Upload //Writes the photo to the server if(move_uploaded_file($_FILES['photo']['tmp_name'], $photo_target)) { echo "<br />The file ".$timestamp_photo. basename( $_FILES['photo']['name']). " has been uploaded. <br />"; } else { echo ""; } //End of Photo/Document Upload //Writes the photo to the server if(move_uploaded_file($_FILES['download1']['tmp_name'], $download_target1)) { echo "<br />The file ".$timestamp_download1. basename( $_FILES['download1']['name']). " has been uploaded. <br />"; } else { echo ""; } //End of Photo/Document Upload //Writes the photo to the server if(move_uploaded_file($_FILES['download2']['tmp_name'], $download_target2)) { echo "<br />The file ".$timestamp_download2. basename( $_FILES['download2']['name']). " has been uploaded. <br />"; } else { echo ""; } //End of Photo/Document Upload //Writes the photo to the server if(move_uploaded_file($_FILES['download3']['tmp_name'], $download_target3)) { echo "<br />The file ".$timestamp_download3. basename( $_FILES['download3']['name']). " has been uploaded. <br />"; } else { echo ""; } //End of Photo/Document Upload echo (mysql_affected_rows()) ? "<br />Edited Branch.<br />" : "<br />Nothing changed. <br />"; } $row = mysql_fetch_array ( mysql_query("SELECT * FROM `ter` WHERE `Ter` = '$ter' ")); ?>
  24. Hi Guys, I have a php script to upload a photo to a mysql table. This works great, until someone uploads a file with the same name, then it replaces the old one. Bad times! So Ive researched it and I have put a timestamp on the filename and it uploads with the correct timestamp in the images folder. However the data that it uploads to the table is just the original filename, ie it doesnt stamp the filename in the table therefore they dont match... Any ideas... <?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 $name=time(); $target = "images/"; $target = $target .$name. 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` = '{$_FILES['photo']['name']}' WHERE `Ter` = '$ter' "; mysql_query($sql) or die(mysql_error()); //Unpause Photo Upload //Writes the photo to the server if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { //Tells you if its all ok echo "<br />The file ". basename( $_FILES['photo']['name']). " has been uploaded. <br />"; } else { //Gives and error if its not echo ""; } //End of Photo Upload echo (mysql_affected_rows()) ? "<br />Edited Branch.<br />" : "<br />Nothing changed. <br />"; } $row = mysql_fetch_array ( mysql_query("SELECT * FROM `ter` WHERE `Ter` = '$ter' ")); ?>
×
×
  • 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.