PHP - Anyone Know The Php Header File Extensions For Sending Attached Documents ??
Hello one and all,
Just a quick request here, I've written a script that sends an email with an attached file by the user. (docx, txt, pdf, doc, rtf) are the formats I have accepted. At the moment I'm sending them with the following... Code: [Select] $fileatt_type = "application/pdf"; // File Type It works fine with all formats in older email clients, i.e, like yahoo before they updated the layout, but in the newer versions it's specific and if I try to send it this way it is always delivered as a .PDF and doesn't open if it is any of the other formats. It may sound silly but I've searched a fair bit for the other extensions or formats to include instead of the above code (maybe something like application/doc or something) but there doesn't seem to be a list. Can anyone point me in the right direction? Much obliged, PHP the learned. Similar Tutorials
How do I only allow jpg and png file extensions to be uploaded as a attachment. My current code is below $msg = ''; if (array_key_exists('userfile', $_FILES)) { // create object of PHPMailer class with boolean parameter which sets/unsets exception. $mail = new PHPMailer(true); try { //$mail->isSMTP(); // using SMTP protocol $mail->Host = 'host'; // SMTP host as gmail $mail->SMTPAuth = true; // enable smtp authentication $mail->Username = 'emailaddress'; // sender gmail host $mail->Password = 'emailpassword'; // sender gmail host password $mail->SMTPSecure = 'ssl'; // for encrypted connection $mail->Port = 587; // port for SMTP $mail->setFrom('emailaddress', "Name"); // sender's email and name $mail->addAddress('emailaddress', "Name"); // receiver's email and name $attachmentNames = []; //Attach multiple files one by one for ($ct = 0; $ct < count($_FILES['userfile']['tmp_name']); $ct++) { $uploadfile = tempnam(sys_get_temp_dir(), hash('sha256', $_FILES['userfile']['name'][$ct])); $filename = $_FILES['userfile']['name'][$ct]; if (move_uploaded_file($_FILES['userfile']['tmp_name'][$ct], $uploadfile)) { if(isset($uploadfile)) $mail->addAttachment($uploadfile, $filename); $attachmentNames[] = $_FILES['userfile']['name'][$ct]; } else { $msg .= 'Failed to move file to ' . $uploadfile; } }
Hi. I'm making a file-sharing website but how do I stop users from uploading certain extensions? Here is my script so far: <?php session_start(); $file_name = $HTTP_POST_FILES['ufile']['name'];$random_digit=rand(0000,9999);$new_file_name=$random_digit.$file_name;$path= "upload/".$new_file_name;if($ufile !=none){if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path)){echo "Successful<BR/>";}else{echo "Error";}}?>() Code works when...
<script type="text/javascript"> var currenttime = '<?php print gmdate('F d, Y H:i:s', time() + (1 * 60 * 60))?>' var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December") var serverdate=new Date(currenttime) function padlength(what){ return (what.toString().length==1)? "0"+what : what } function displaytime(){ serverdate.setSeconds(serverdate.getSeconds()+1) var datestring=montharray[serverdate.getMonth()]+" "+padlength(serverdate.getDate())+", "+serverdate.getFullYear() var timestring=padlength(serverdate.getHours())+":"+padlength(serverdate.getMinutes())+":"+padlength(serverdate.getSeconds()) document.getElementById("servertime").innerHTML=datestring+" "+timestring } window.onload=function(){ setInterval("displaytime()", 1000) } </script>Code not works when... <script type="text/javascript" src="clock.js">I want to use second option. Any help? Hi guys I have created these codes below, uploadform.php Code: [Select] <html> <head> </head> <body> <form action="upload.php" method="post" enctype="multipart/form-data"> <table> <tr> <td><div align="left">Submit photo </div></td> <td><div align="left"> <input type="file" name="file" id="file" /> </div></td> </tr> <tr> <td><div align="left"></div></td> <td><div align="left"> <input type="submit" name="Submit" value="Submit" /> </div></td> </tr> </table> </form> </body> </html> upload.php Code: [Select] <?php /************************ * Upload file *************************/ if (isset($_POST['Submit'])) { //if "email" is filled out, send email /*** Upload File ***/ if($_FILES["file"]["size"] < 20000) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { //echo "Upload: " . $_FILES["file"]["name"] . "<br />"; //echo "Type: " . $_FILES["file"]["type"] . "<br />"; //echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; //echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; if (file_exists("upload/" . $_FILES["file"]["name"])) { //$_FILES["file"]["name"] // Do nothing... } else { move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); $url = "http://asiamodeltalent.com/php/mt/" . "upload/" . $_FILES["file"]["name"]; } } } else { echo "Invalid file"; } /************************ * Insert path and filename to array *************************/ $fname = $_FILES["file"]["name"]; $files = array("$fname"); /************************ * Send Message to email *************************/ $to = "iridion_us@yahoo.com"; $from = "contact@coder9.com"; $subject ="Email File"; $message = "Test email with file attached.\n"; $headers = "From: $from"; // boundary $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; // headers for attachment $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; // multipart boundary $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"; $message .= "--{$mime_boundary}\n"; // preparing attachments $pathupload = "http://coder9.com/php/mt/" . "upload/"; for($x=0;$x<count($files);$x++){ //$file = fopen($files[$x],"rb"); $file = fopen($url[$x], "rb"); //$data = fread($file,filesize($files[$x])); $data = fread($file, filesize($url[$x])); fclose($file); $data = chunk_split(base64_encode($data)); $message .= "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$files[$x]\"\n" . "Content-Disposition: attachment;\n" . " filename=\"$files[$x]\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n"; $message .= "--{$mime_boundary}\n"; } // send $ok = @mail($to, $subject, $message, $headers); if ($ok) { echo "<p>mail sent to $to!</p>"; } else { echo "<p>mail could not be sent!</p>"; } } ?> The problem with this codes is the file is attached but it's empty. By the way if you want to test it you need a sub directory of /upload What is the cause of this problem? Thanks in advanced. Hi all, I am trying to send an image through header so I have two php files: test0.php Code: [Select] <html> <head> </head> <body> <?php $imagename='test.php'; ?> <img src="<?php echo $imagename; ?>"/> </body> </html> and test.php: Code: [Select] <html> <html> <head> </hesd> <body> <?php $image = imagecreatefromjpeg('images/1.jpg'); header('Content-Type: image/jpeg'); imagejpeg($image, '', 100); ?> </body> </html> but the image doesn't show . What is the correct way? Thank you in advance. I need to send two cookie name/value pairs to the page I am trying to open using file_get_contents, in order for the person viewing the page to have associated dynamic content, but it isn't working, and I'm wondering if I'm setting it up right: if(isset($_COOKIE['bwd_data']) && isset($_COOKIE['bwd'])){ $cookie_val = $_COOKIE['bwd_data']; $cookie_val2 = $_COOKIE['bwd']; $opts = array( 'http'=>array( 'method'=>"GET", 'header'=>"Accept-language: en\r\n" . "Cookie: bwd_data=" . $cookie_val . "\r\n" . "Cookie: bwd=" . $cookie_val2 ) ); $context = stream_context_create($opts); echo(file_get_contents(url::site('httperrors','http'), FALSE , $context)); }else{ echo(file_get_contents(url::site('httperrors','http'))); } Hello, Can someone help me with these contact-form please, I just want to include a file (.pdf, .jpg, .png) and send the mail.
For the moment, the mail is send but not with the file included.
Here is the website http://www.coeuraprendre.art
HTML CODE :
<form id="contact-form" class="checkform" action="#" target="contact-send.php" method="post" enctype="multipart/form-data" > <div class="form-row clearfix"> <label for="name" class="req">Nom *</label> <input type="text" name="name" class="name" id="name" value="" placeholder="Name" /> </div> <div class="form-row clearfix"> <label for="email" class="req">Email *</label> <input type="text" name="email" class="email" id="email" value="" placeholder="Email"/> </div> <div class="form-row clearfix textbox"> <label for="message" class="req">Nom du projet *</label> <textarea name="message" class="message" id="message" rows="15" cols="50" placeholder="Message"></textarea> </div> <div class="form-row clearfix"> <label for="pdf" class="req">Ajoutez votre dossier d'inscription (Pdf intéractif) *</label> <input type="file" id="pdf" class="pdf" name="pdf" placeholder="Pdf" accept="image/pdf"> </div> <div id="form-note"> <div class="alert alert-error"> <strong>Error</strong>: Please check your entries! </div> </div> <div class="form-row form-submit"> <input type="submit" name="submit_form" class="submit" value="Send" /> </div> <input type="hidden" name="subject" value="From Coeur à Prendre" /> <input type="hidden" name="fields" value="name,email,message," /> <input type="hidden" name="sendto" value="info@coeuraprendre.art" /> </form> </div> <!-- Contact form -->
PHP CODE :
<?php define("WEBMASTER_EMAIL", $_POST['sendto']); if (WEBMASTER_EMAIL == '' || WEBMASTER_EMAIL == 'Testemail') { die('<div class="alert alert-confirm"> <h6><strong>The recipient email is not correct</strong></h6></div>'); } define("EMAIL_SUBJECT", $_POST['subject']); if (EMAIL_SUBJECT == '' || EMAIL_SUBJECT == 'Subject') { define("EMAIL_SUBJECT",'Contact'); } $name = stripslashes($_POST['name']); $email = trim($_POST['email']); $message = stripslashes($_POST['message']); $pdf = stripslashes($_POST['pdf']); $custom = $_POST['fields']; $custom = substr($custom, 0, -1); $custom = explode(',', $custom); $message_addition = ''; foreach ($custom as $c) { if ($c !== 'name' && $c !== 'email' && $c !== 'message' && $c !== 'pdf' && $c !== 'subject') { $message_addition .= '<b>'.$c.'</b>: '.$_POST[$c].'<br />'; } } if ($message_addition !== '') { $message = $message.'<br /><br />'.$message_addition; } $message = '<html><body>'.nl2br($message)."</body></html>"; $mail = mail(WEBMASTER_EMAIL, EMAIL_SUBJECT, $message, "From: ".$name." <".$email.">\r\n" ."Reply-To: ".$email."\r\n" ."X-Mailer: PHP/" . phpversion() ."MIME-Version: 1.0\r\n" ."Content-Type: text/html; charset=utf-8"); if($mail) { echo ' <div class="alert alert-confirm"> <strong>Confirm</strong>: Your message has been sent. Thank you! </div> '; } else { echo ' <div class="alert alert-error"> <strong>Error</strong>: Your message has not been send! </div> '; } ?> Edited July 22 by cocolembo Cannot modify header information - headers already sent by (output started at ) on line 179 I labeled 179 its at the bottom. I understand this means its already generating the html but not how or where. A solution would of course be nice but if some one could tell me even how to figure it out it would be great. Code: [Select] <?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "test@test.com"; $email_subject = "$mile"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } /*"trail_section_mile", float dash "trail_section_name", #9()alphanumeric "name", "date"auto date "email",same "telephone" same "trail_condition" no validation just sanitize size limit "attention_area" no validation just sanitize size limit "under_20" no validation just sanitize size limit "_20_54" no validation just sanitize size limit "_55_over" no validation just sanitize size limit */ if(!isset($_POST['trail_section_mile']) ) { died('1'); } if(!isset($_POST['trail_section_name']) ) { died('2'); } if(!isset($_POST['name']) ) { died('3'); } if(!isset($_POST['email']) ) { died('4'); } if(!isset($_POST['telephone']) ) { died('5'); } if(!isset($_POST['trail_condition']) ) { died('6'); } if(!isset($_POST['attention_area']) ) { died('7'); } if(!isset($_POST['under_20']) ) { died('8'); } if(!isset($_POST['_20_54']) ) { died('9'); } if(!isset($_POST['_55_over']) ) { died('0'); } if(!isset($_POST['total_hours']) ) { died('011'); } //comments field is a honeypot require ('Validate.php'); $email = $_REQUEST['email']; $validate = new Validate(); if (!Validate::email($email, array('check_domain' => true, 'use_rfc822' =>true))) { echo "Invalid email"; } $trail_section_mile = $_POST['trail_section_mile']; // required $trail_section_name = $_POST['trail_section_name']; // required $name = $_POST['name']; // required $email = $_POST['email']; // required $telephone = $_POST['telephone']; // required $trail_condition = $_POST['trail_condition']; // required $attention_area = $_POST['attention_area']; // required $under_20 = $_POST['under_20']; $_20_54 = $_POST['_20_54']; $_55_over = $_POST['_55_over']; $_55_over = $_POST['total_hours']; // required if (preg_match('/[\d\D\b\B\s\S]/', $comments)) { echo "nope"; } if (!preg_match("/([\w\.\#\-\,]{1,30})+/", $trail_section_mile)) {echo "please enter the section mile markers again only numbers, decimals dashes and # are aloud"; } if (!preg_match("/[a-z'-]+/", $trail_section_name)) { echo "Try your last name again."; } if (!preg_match("/[a-z'-]+/", $name)) { echo "please re-type your address."; } if (!preg_match("/^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/i", $telephone)) { echo "Something is wrong with the phone number you intered. Please enter your area code first then ther rest of tyour number."; } if (( preg_match( "/[\r\n]/", $first_name ) || preg_match( "/[\r\n]/", $email ) || preg_match( "/[\r\n]/", $last_name) ) || preg_match( "/[\r\n]/", $state)) { echo "nope"; } $trail_section_mile = strip_tags($trail_section_mile); $trail_section_name = strip_tags($trail_section_name); $name =strip_tags($name); $email = strip_tags($email); $telephone = strip_tags($telephone); $trail_condition = strip_tags($trail_condition); $attention_area = strip_tags($attention_area); $under_20 = strip_tags($under_20); $_20_54 = strip_tags($_20_54); $_55_over = strip_tags($_55_over); $total_hours = strip_tags($total_hours); $trail_section_mile = htmlspecialchars($trail_section_mile); $trail_section_name = htmlspecialchars($trail_section_name); $name = htmlspecialchars($name); $email = htmlspecialchars($email); $telephone = htmlspecialchars($telephone); $trail_condition = htmlspecialchars($trail_condition); $attention_area = htmlspecialchars($attention_area); $under_20 = htmlspecialchars($under_20); $under_20 = htmlspecialchars($_20_54); $_55_over = htmlspecialchars($_55_over); $total_hours = htmlspecialchars($total_hours); $email_message = "Form details below.\n\n"; $email_message = date("m/d/Y") . "\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Trail Section Mile Markers: ".clean_string($trail_section_mile)."\n"; $email_message .= "Trail Section Name : ".clean_string($trail_section_name)."\n"; $email_message .= "Reported by: ".clean_string($name)."\n"; $email_message .= "Email Address: ".clean_string($email)."\n"; $email_message .= "Telephone Number: ".clean_string($telephone)."\n"; $email_message .= "General Trail Condition : ".clean_string($trail_condition)."\n"; $email_message .= "Mile #/Problem/Suggested Improvements: ".clean_string($attention_area)."\n"; $email_message .= "Volunteers Under Age 20 #Males/#Females/Ethnicity/Name: ".clean_string($under_20)."\n"; $email_message .= " Volunteers Ages 20 to 54 #Males/#Females/Ethnicity/Name: ".clean_string($_20_54)."\n"; $email_message .= "Volunteers Age 55+ #Males/#Females/Ethnicity/Name: ".clean_string($_55_over)."\n"; $email_message .= "Total Volunteer Hours: ".clean_string($total_hours)."\n"; $about ="Maintenance Report from" .$name. "/n"; // create email headers $headers = 'Subject : '.$about."/r/n" .'From: '.$email."\r\n" .'Reply-To: '.$email."\r\n" . 'X-Mailer: PHP/' . phpversion(); header("Location: oht/maintenance/maintenance-report/thank-you/"); //line 179 @mail($email_to, $email_subject, $email_message, $headers); ?> <?php } ?> MOD EDIT: [code] . . . [/code] BBCode tags added. Alright so I've got some files being generated on the fly via database information. User clicks a button, which gathers that database information, puts it all into a file (*.tpl - which is really just an html page), then sends the file to the printer. Question is, how do I send the file to the printer queue of the computer that viewed the webpage? On a side note, is it easier/better to do the HTML layout or write a default.doc, then read that and copy the files to a new file and print that? or perhaps just hit a 'view & print' button, which opens up in a new window the size of the 'image' that needs to be printed, and have a print button on that page. Ok, I have tried using the code from this link http://answers.yahoo.com/question/index?qid=20100927173625AAmEmiW Code: [Select] <?php // Get the name they entered in the form // We'll be naming the file this $file = $_POST['name']; // Get the email from the form $email = $_POST['email']; // We want the file to be a text file right? $ex = ".txt"; // Try to open a file named $file$ex (johndoe.txt for example) // Because this file doesn't exist yet the server creates it $write = fopen("$file$ex","w"); // Now open the file up again but this time save the email in it fwrite($write,$email); // MAKE SURE you close the file!!! fclose($write); // The folder that this script is in on the server is where the file we just made was saved // We can 'rename' it to another folder // The folder on the server we want to move it to $data = "../emails/"; // Now put it all together: This example goes out of the folder we're in and into the folder 'emails' // The new 'name' would be this now (../emails/johndoe.txt): So now the file is moved to where we want for storage rename ("$file","$data$file$ex"); // The script is done, send the user to another page (Just read the address below and you'll get it) exit; ?> unfortunately it doesn't do as i would like. I'm not sure how to get it to save a new file based on a variable on the form page or from one of the fields in the form. What i need is a way for a user to submit the form and it save the data into a uniquely named csv file. I know the code given is for text files, not csv, but that was about all i could find. If there is any help i would greatly appreciate it. Does anyone know of a way to use PHP to create and email a HTML file? I was attempting to use the standard PHP mail function to pass a HTML string to the message variable, but mail clients have a pretty hard time rendering HTML/CSS correctly. My thought was, if I could take my HTML string and turn it into a file and attach it to a email message the user would be able to open the file in there default browser which would render without issues. Just for the record my HTML string also contains PHP variables, so it must be processes before being sent. So far my research suggests using the PEAR library for sending mail with attachments, but I am only finding literature on how to attach a file already existing on the server to an email message. I am having trouble finding a way to create a HTML file on the fly and attach it to an email message. Has anyone had a similar problem? Is there a different way to accomplish what I am attempting to do here? So here is my code: //form.html <form action="http://localhost/lab3/index.php" method="post " > <input type="text" name="numar" value=""><br> <input type="submit" name="submitButton" value="Submit"> </form> //and in index.php ,which is in the specified folder if I write : if($_POST['numar']!="") $m=$_POST['numar']; //then I get an error saying Undefined index: numar I really read a lot about forms and saw examples , but I can't figure out what's wrong. If you have any ideas.. By default, PHP comes with some extensions disabled. Question 1: Is there a command (via command-line) to enable ALL extensions? Question 2: Are there any drawbacks to having all extensions enabled (e.g. slows it down, conflicts, etc.)? Thank you. I want these two extensions to work together Note that the plugin has 2 codes 1 https://wordpress.org/plugins/qty-increment-buttons-for-woocommerce/ 2 https://wordpress.org/plugins/woo-product-price-x-quantity-preview/#installation Hello
So I want to try and match everything preceding a file extension in a string using preg_match.
An example file name: "Images_home_blah.blah.jpg" .
I've tried the following regex:
/^([a-z0-9_\-\.]+)(?!\.jpg)/iBut this sadly appears to capture the whole string instead of ignoring the '.jpg' part. Can anyone point me in the right direction? Thanks, Drongo I have a problem, when my script is executed it doesn't grab the file but returns all the source code on the page in a text document The text file hasn't been over written. Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252" /> <title>Ajicles File Hosting - Downloading:040810051842songs.txt</title> <link rel="stylesheet" type="text/css" href="style.css" /> <!--[if IE 6]> <link rel="stylesheet" type="text/css" href="iecss.css" /> <![endif]--> </head> <body> <div id="main_container"> <div id="header"> <div id="logo"><a href="index.html"><img src="images/logo.png" alt="" title="" border="0" width="251" height="82"/></a></div> <div id="menu_tab"> <ul class="menu"> <li><a href="index.php" class="nav"> Home </a></li> <li><a href="upload.php" class="nav"> Upload</a></li> <li><a href="login.php" class="nav"> Login</a></li> <li><a href="register.php" class="nav"> Register</a></li> <li><a href="contact.php" class="nav"> Contact </a></li> <li><a href="logout.php" class="nav"> Logout </a></li> </ul> </div> </div> <div id="main_content"> <div id="downloading"> </div> </div> <div class="clear"></div> </div> <!-- main_content--> <div id="footer"> <img src="images/footer_logo.gif" alt="" title="" width="33" height="45" class="left" /> <div class="left_footer"> Ajicles Hosting 2010. All Rights Reserved </div> </div> </div> </body> </html> Hello everyone! I'm somewhat of a newb in this so anyways I have this script and I try to force a browser to download a file when someone hits a download button. here is what I'm trying: header('Content-Type: application-download'); header('Content-Disposition: attachment; filename=' .basename($dl_id)); readfile($dl_id); It seems to work in Chrome, Firefox, but it doesn't work in IE Any suggestions? The root directory:
header.php
stylesheet.css
In the following example I am trying to include the header.php file in a sub folder.
When I include the header.php like in the following example then the stylesheet.css file will not work anymo
<?php include("../header.php"); ?>The stylesheet.css file is included in the head tags of the header.php file. Is the above example the right way to do it? If yes, how can I do it so the stylesheet.css file will work too. I'm working on a member modification page that works off of the javascript "onblur" method. Ideally the way I want it to work is when a person leaves the field they were in the second php script runs and returns to the page a value to the page. Right now it does just that with one problem - it won't run the attached script twice if the values are the same twice. For instance: If I'm tabbing through the fields several times for whatever reason and accidentally add an "a" to the name field one of those times, i realize this and want to go back to fix it. After I've fixed it I tab out and what should happen is the script runs, the new info is written to the databse, and the script returns new info for the page. What is currently happening is nothing - it doesn't seem to run the script. Using Chrome I see that it's executing the script but it isn't writing back to the page or updating the database. Any help or pointers I could get would be very welcome. Thanks! Scripts Below and attached: Member Edit Page: <?php $title = "TAPCO File Upload Data"; $top1 = "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'> <html xmlns='http://www.w3.org/1999/xhtml'> <head> <meta http-equiv='Content-Type' content='text/html; charset=UTF-8' /> <title>"; $top2 = "</title> <link href='css.css' rel='stylesheet' type='text/css' /> <script type='text/javascript'> function attach_file( p_script_url ) { // create new script element, set its relative URL, and load it script = document.createElement( 'script' ); script.src = p_script_url; document.getElementsByTagName( 'head' )[0].appendChild( script ); } </script> </head> <body>"; $host="localhost"; // Host name $username="ftpuploads"; // Mysql username $password="password"; // Mysql password $db_name="ftpuploads"; // Database name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $unam = $_GET["unam"]; $q = "select * from members where username = '".$unam."'"; $r = mysql_query($q); $name = mysql_result($r, 0, 'name'); $email = mysql_result($r, 0, 'email'); $sp = mysql_result($r, 0, 'sp'); $sno = mysql_result($r, 0, 'sno'); $snow = "Sales Number: ".str_pad(mysql_result($r, 0, 'sno'), 3, 0, STR_PAD_LEFT); $fa = mysql_result($r, 0, 'fa'); $user = mysql_result($r, 0, 'user'); $admin = mysql_result($r, 0, 'admin'); $active = mysql_result($r, 0, 'active'); mysql_close(); if ($user == "0" && $admin == "1") { $disuoa = "Admin"; } elseif ($user == "1" && $admin == "0") { $disuoa = "User"; } else { die("Something is wrong, both admin and user have the same value"); } if ($active == "1") { $disactive = "Active"; } else { $disactive = "Inactive"; } if ($sp == "0") { $spcell = "<option value='1'>Yes</option> <option value='0' selected>No</option>"; } else { $spcell = "<option value='1' selected>Yes</option> <option value='0'>No</option>"; } if ($fa == "0") { $facell = "<option value='1'>Yes</option> <option value='0' selected>No</option>"; } else { $facell = "<option value='1' selected>Yes</option> <option value='0'>No</option>"; } if ($user == "0" && $admin == "1") { $uoacell = "<option value='User'>User</option> <option value='Admin' selected>Admin</option>"; } else { $uoacell = "<option value='User' selected>User</option> <option value='Admin'>Admin</option>"; } if ($active == "0") { $actcell = "<option value='1'>Yes</option> <option value='0' selected>No</option>"; } else { $actcell = "<option value='1' selected>Yes</option> <option value='0'>No</option>"; } echo $top1.$title.$top2; echo "<span id='disname'>".$name."</span><br /> <span id='disuname'>".$unam."</span><br /> <span id='disemail'>".$email."</span><br /> <br /><span id='dissno'>".$snow."</span><br /> <br /><span id='disuoa'>".$disuoa."</span><br /> <br /><span id='disactive'>".$disactive."</span><br /><br />"; echo "<form> <table> <tr> <td> Name </td> <td> Password </td> <td> Sales Person? </td> <td> Sales Number </td> <td> Full Access? </td> <td> User or Admin? </td> <td> Active? </td> </tr> <tr> <td> <input type='text' name='name' value='".$name."' onblur=\"javascript:attach_file('updatefield.php?span=disname&unam=".$unam."&fchan=name&val='+this.value)\" /> </td> <td> <span id='passres'><a href=\"javascript:attach_file('resetpassword.php?uname=".$unam."&email=".$email."')\">Reset and Send</a></span> </td> <td> <select name='sp' onblur=\"javascript:attach_file('updatefield.php?span=&unam=".$unam."&fchan=sp&val='+this.value, this.value)\"> ".$spcell." </select> </td> <td> <input type='text' name='sno' onblur=\"javascript:attach_file('updatefield.php?span=dissno&unam=".$unam."&fchan=sno&val='+this.value)\" /> </td> <td> <select name='fa'> ".$facell." </select> </td> <td> <select name='uoa'> ".$uoacell." </select> </td> <td> <select name='active'> ".$actcell." </select> </td> </table> </form> "; ?> updatefield page: <? $host="localhost"; // Host name $username="ftpuploads"; // Mysql username $password="password"; // Mysql password $db_name="ftpuploads"; // Database name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); header( 'Content-Type: text/javascript' ); $span = $_GET['span']; $username = $_GET['unam']; $fchan = $_GET['fchan']; $val = $_GET['val']; $q = "select ".$fchan." from members where username = '".$username."'"; $r = mysql_query($q); $fchanOrVal = mysql_result($r, 0, name); if ($fchanOrVal == $val) { die(); } else { $qu = "update members set ".$fchan." = '".$val."' where username = '".$username."'"; $ru = mysql_query($qu); echo "if ('".$span."' != '') { fchan_span_obj = document.getElementById( '".$span."' ); fchan_span_obj.innerHTML = '".$val."'; } else if ('".$span."' == '') { }"; } mysql_close(); ?> I want to call a different header file for firefox. Is this possible? I don't need to adjust anything in the css file. How can I do this? |