Jump to content

Search the Community

Showing results for tags 'PHP'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Calendars

  • Community Calendar

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 981 results

  1. What are the advantages & disadvantages of PHP & JavaScript? Can anyone demonstrate the situations with code where it is better to make use of PHP and situations where it is better off to apply JavaScript? I'm asking this to best implement both the languages! Thanks in advance to the people who can help me! Thank you!
  2. please help I know it's something silly , i cannot get the selecter checkboxes to send to the mail index.php <?phpsession_name("fancyform");session_start();$_SESSION['n1'] = rand(1,20);$_SESSION['n2'] = rand(1,20);$_SESSION['expect'] = $_SESSION['n1']+$_SESSION['n2'];$str='';if($_SESSION['errStr']){ $str='<div class="error">'.$_SESSION['errStr'].'</div>'; unset($_SESSION['errStr']);}$success='';if($_SESSION['sent']){ $success='<h1>Thank you!</h1>'; $css='<style type="text/css">#contact-form{display:none;}</style>'; unset($_SESSION['sent']);}?><!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>Henster Feedback Form </title><link rel="stylesheet" type="text/css" href="jqtransformplugin/jqtransform.css" /><link rel="stylesheet" type="text/css" href="formValidator/validationEngine.jquery.css" /><link rel="stylesheet" type="text/css" href="demo.css" /><?=$css?><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script><script type="text/javascript" src="jqtransformplugin/jquery.jqtransform.js"></script><script type="text/javascript" src="formValidator/jquery.validationEngine.js"></script><script type="text/javascript" src="script.js"></script></head><body><div id="main-container"> <div id="form-container"> <h1>Hensters Feedback Form</h1><br><br> <h2>Drop us a line and we will get back to you</h2> <form id="contact-form" name="contact-form" method="post" action="submit.php"> <table width="100%" border="0" cellspacing="0" cellpadding="5"> <tr> <td width="15%"><label for="name"><Name</label></td> <td width="70%"><input type="text" class="validate[required,custom[onlyLetter]]" name="name" id="name" value="<?=$_SESSION['post']['name']?>" /></td> <td width="15%" id="errOffset"> </td> </tr> <tr> <td><label for="email">Email</label></td> <td><input type="text" class="validate[required,custom[email]]" name="email" id="email" value="<?=$_SESSION['post']['email']?>" /></td> <td> </td> </tr> <tr> <td><label for="subject">Subject</label></td> <td><select name="subject" id="subject"> <option value="" selected="selected"> - Choose -</option> <option value="Question">Question</option> <option value="Business proposal">Business proposal</option> <option value="Advertisement">Advertising</option> <option value="Complaint">Complaint</option> </select> </td> <td> </td> </tr> <tr> <td valign="top"><label for="message">Message</label></td> <td><textarea name="message" id="message" class="validate[required]" cols="35" rows="5"><?=$_SESSION['post']['message']?></textarea></td> <td valign="top"> </td> </tr> <tr> <td><label for="series">series</label></td> <td><input type="checkbox" name="series" id="series" value="series ” /><?=$_SESSION['post']['value']?> </td> <td valign="top"> </td> <tr> <td> <label FOR="blue">blue</label></td> <td> <input type="checkbox" name="check[]" value="blue"><?=$_SESSION['post']['value']?></td></tr><br> <h2>Select the Series </h2> <tr> <td><label for="captcha"><?=$_SESSION['n1']?> + <?=$_SESSION['n2']?> =</label></td> <td><input type="text" class="validate[required,custom[onlyNumber]]" name="captcha" id="captcha" /></td> <td valign="top"> </td> </tr> <tr> <td valign="top"> </td> <td colspan="2"><input type="submit" name="button" id="button" value="Submit" /> <input type="reset" name="button2" id="button2" value="Reset" /> </tr> <?=$str?> <img id="loading" src="img/ajax-load.gif" width="16" height="16" alt="loading" /></td> </tr> </table> </form> <?=$success?> </div> <div class="tutorial-info"> This is a Henster Feedback Page</div></body></html> and my submit.php ?php/* config start */$emailAddress = 'info@henster.co.za';/* config end */require "phpmailer/class.phpmailer.php";session_name("fancyform");session_start();foreach($_POST['check'] as $value) {$check_msg .= "Checked: $value\n";}foreach($_POST as $k=>$v){ if(ini_get('magic_quotes_gpc')) $_POST[$k]=stripslashes($_POST[$k]); $_POST[$k]=htmlspecialchars(strip_tags($_POST[$k]));}$err = array();if(!checkLen('name')) $err[]='The name field is too short or empty!';if(!checkLen('email')) $err[]='The email field is too short or empty!';else if(!checkEmail($_POST['email'])) $err[]='Your email is not valid!';if(!checkLen('subject')) $err[]='You have not selected a subject!';if(!checkLen('message')) $err[]='The message field is too short or empty!';if((int)$_POST['captcha'] != $_SESSION['expect']) $err[]='The captcha code is wrong!';if(count($err)){ if($_POST['ajax']) { echo '-1'; } else if($_SERVER['HTTP_REFERER']) { $_SESSION['errStr'] = implode('<br />',$err); $_SESSION['post']=$_POST; header('Location: '.$_SERVER['HTTP_REFERER']); } exit;}$msg='Name: '.$_POST['name'].'<br />Email: '.$_POST['email'].'<br />IP: '.$_SERVER['REMOTE_ADDR'].'<br /><br />Series Selected : '.$_POST['value'].'<br />Message:<br /><br />'.nl2br($_POST['message']).'';if($_POST['consultancy']==1) { $msg.='Consultancy: '.$_POST['consultancy']; }$mail = new PHPMailer();$mail->IsMail();$mail->AddReplyTo($_POST['email'], $_POST['name']);$mail->AddAddress($emailAddress);$mail->SetFrom($_POST['email'], $_POST['name']);$mail->Subject = "A new ".mb_strtolower($_POST['subject'])." from ".$_POST['name']." | contact form feedback";$mail->MsgHTML($msg);$mail->Send();unset($_SESSION['post']);if($_POST['ajax']){ echo '1';}else{ $_SESSION['sent']=1; if($_SERVER['HTTP_REFERER']) header('Location: '.$_SERVER['HTTP_REFERER']); exit;}function checkLen($str,$len=2){ return isset($_POST[$str]) && mb_strlen(strip_tags($_POST[$str]),"utf-8") > $len;}function checkEmail($str){ return preg_match("/^[\.A-z0-9_\-\+]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/", $str);}?>
  3. I have mail function which gets mail message from a textarea. But whenever there is apostrophes and new line it show it like below. Example Output: Comments: You\\'re mailing address was wrong. Couldn\\'t you provide an other? Survey Answers: item : You\\'re making it well. Isn\\'t it?\nitem2 : It\\'d better to have a cup of tea?\n 1) There are three slashes added along with apostrophes. Is it likely something to do with magic escaping? is the stripslashes function the better option to remove it? 2) New line converted to \r\n. The issue is the \r\n might be a windows artifact. On a Linux server it might be \n only. Is it would be enough to use str_replace('\r\n', "\n", $message); ? Then str_replace("\n", "", $message); ?
  4. My goal is to send an email at the time indicated below. (Every weds at 12). Here is my current code: <?php date_default_timezone_set('MST');$file = $_SERVER['DOCUMENT_ROOT'] . "/entries.txt"; //Path to your *.txt file$contents = file($file);$string = implode("", $contents); $to = "april@coastalmountaincreative.com";$subject = "My subject";$txt = $string;$header = "From: scott@avvecc.com"; $d = date( "w");$h = date( "G"); if ($d == 3) {if ($h == 12) { mail($to,$subject,$txt,$header);file_put_contents("entries.txt", "");}} ?> It works great, however if no one visits the page at 12 that day it never gets sent. How can I make it so it sends no matter what? Thanks.
  5. I am having this problem using mime mail to send e-mail with multiple cc recipients. To be exact, if I have more than 2 e-mail address in the cc list, starting from 3rd recipient onward, none of them in the cc list is able to receive the e-mail. To put it in another word, only first 2 recipients in the cc list is able to receive the e-mail.. I have no idea what happened at all, hope somebody can give me some direction. <?php require_once 'mail.php'; require_once 'mime/mime.php'; $mailTo = array( 'x@abc.com', ); $mailCc = array( 'a@abc.com', 'b@abc.com', // receipient set after this will not be able to receive the e-mail 'c@abc.com', ); $headers['Subject'] = 'PHP mail test'; $headers['From'] = 'phpmailteam@abc.com'; $headers['Cc'] = implode(', ', $mailCc); $message = 'Test send text e-mail'; $mime =& new Mail_Mime; $result = $mime->setTXTBody($message); $mbody = $mime->get(); $headers = $mime->headers($headers); $mail =& Mail::factory('mail'); $result = $mail->send($mailTo, $headers, $mbody);?>
  6. Greetings everyone, and thank you to the mods for allowing my account so rapidly! For a week or so now I've been trying to find information on how file uploads are stored in PhP. I'm creating an html photo upload form. I've figured everything out, except for how to handle the files. When you have: <form action="store.php" method="post" enctype="multipart/form-data"> <input type="file" name="images" multiple="multiple"></form> I know that for a single file $_FILES["images"]["tmp_name"] is where the file would be temporarily stored on the server. However, only one image is being stored here, not the two or three that I'm selecting using the upload form. Any assistance or tips would be greatly appreciated!
  7. Hi everybody,it's been a couple of days that i'm trying to show the values inside a multidimensional array but unsuccessfully. This is my code: $i=0;$countLow=0;$fissoLow=0;for ($i=0;$i<10; $i++){ $z+=2; $fissoLow = 10*2*$z; $countLow = $fissoLow*$z; $res=array("fissi" => array($fissoLow),"conteggi" => array($countLow)); }for ($j=0; $j<count($res); $j++){ echo $res['fissi'][$j] . " " . $res['conteggi'][$j] . "<br />"; } And this is the (wrong) result: 400 8000 This should be the last row of $res array, not the only one. Waiting your replies
  8. Hi, I have make a form in which user will enter his salesforce username and password and the i have to login to saleforce system and get the all the contacts details. and then save to my php database. Please suggest any code for this. Thanks,
  9. hey anyone, i have a problem about passing variable. gridpEmp.PHP <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><HTML><HEAD><TITLE></TITLE><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta http-equiv="Content-Style-Type" content="text/css"><meta http-equiv="Content-Script-Type" content="text/javascript"><script type="text/javascript">var preEl ;var orgBColor;var orgTColor;function HighLightTR(el, backColor,textColor){ var rowindex = el.sectionRowIndex; if(typeof(preEl)!='undefined') { preEl.bgColor=orgBColor; try{ChangeTextColor(preEl,orgTColor);}catch(e){;} } orgBColor = el.bgColor; orgTColor = el.style.color; el.bgColor=backColor; try{ChangeTextColor(el,textColor);}catch(e){;} preEl = el;}function ChangeTextColor(a_obj,a_color){ ; for (i=0;i<a_obj.cells.length;i++) a_obj.cells(i).style.color=a_color;}<style>table.selectable-table td { font-size:10pt; font-family: Arial; }table.selectable-table td { cursor:pointer; margin:0px; border:0px; padding:2px 5px 2px 5px; }table.selectable-table { border-spacing:0px; background:#eef;}</style></script></HEAD><BODY><table id="gridemp" border="1" cellspacing="0" cellpadding="4" align="center"><th>Employee Initial</th><th>Employee ID</th><th>Employee Name</th><tbody><?phpinclude('check/conDBodbc.php');$empid = $_POST['searchemployee']; function dbquery($sql) {include('check/conDBodbc.php'); $arr = array(); $rs = odbc_exec($con,$sql); $x = 1; while (odbc_fetch_row($rs)) { for ($y = 1; $y <= odbc_num_fields($rs); $y++) $arr[$x][$y] = odbc_result($rs,$y); $x++; } if ($x > 1) return $arr;}$arr = dbquery("select * from getemployee where employeeid like '%$empid%' or employeename like '%$empid%' or employeeinitial like '%$empid%'");echo $arr[1][3]; $rs1 = odbc_exec($con,"select * from getemployee where employeeid like '%$empid%' or employeename like '%$empid%' or employeeinitial like '%$empid%'");while(odbc_fetch_array($rs1)){?><tr onClick="HighLightTR(this,'#c9cc99','cc3333')"><!--<tr onClick="getvalue(this)">--><td align=left><?php echo odbc_result($rs1,employeeinitial);?></td><td align=left><?php echo odbc_result($rs1,employeeid);?></td><td align=left><?php echo odbc_result($rs1,employeename);?></td></tr><?php }?></tbody></table></BODY></HTML> i want to passing variable var rowindex = el.sectionRowIndex;how to do that passing variable in one file php??because i want to get value of row index from user selected row after that i can echo value of selected row from user by function dbquery($sql).
  10. sonu

    PHP & MYSQL Help

    Hi Guys! I have 2 fields name & email in mysql database.I want to check if the record exists or not in the DB and if not then it would insert records in the database. Quick help really appreciated. Thanks!
  11. Hi guys,I'm trying to integrate an online rich text editor in my web site.I have found an HTML code that create an awesome rich text editor and I want to keep using it for my site, but in the tutorial, the author don't have write the code to allow the user to save the file (with the bold, underline ecc propriets) on their PC.Now, the rich text editor is in a private area, with you can access with a login written in PHP ad MySQL and I want that the file will not be saved in their PC but I want that the file will be saved in a directory (in my server) witch only the owner of the file can access the file with the login. I want also that the file must have a 'name'.I want that the saved file will be appear in a list in a page and with a click in the file's title, it will be opened in the editor page.Sorry for my bad English but I'm an Italian user :)I know that this is very difficult but i really need this rich text editor with the save option.I have posted in PHP zone because I think that the script to save the file must be written in PHP to work with MySQL. Here you can found the code: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"><html> <head><style type="text/css">/*<![CDATA[*/#editor {width: auto;height: auto;}#firefoxerror {display: none;/*]]>*/</style><meta content="text/html; charset=utf-8" http-equiv="Content-Type"><title>Senza nome 1</title><style type="text/css">.auto-style1 {font-family: Tahoma;}</style></head><body onLoad="def()"><script type="text/javascript">if (navigator.userAgent.indexOf("Firefox")!=-1)document.write("L' editor non supporta Firefox. Usate Internet Explorer, Google Chrome, Safari o Opera.")</script><center><div id="editor"><div style="width:549px; text-align:left; margin-bottom:10px"><table style="width: 103%"><tr><td class="auto-style1" style="width: 209px"><a href="http://my.lightschool.it/login-home.php">← Torna indietro</a></td><td style="width: 38px"><img src="http://cdn4.iconfinder.com/data/icons/meBaze-Freebies/32/save.png" height="26" width="26"></td><td><img src="http://cdn1.iconfinder.com/data/icons/CrystalClear/32x32/actions/agt_print.png" height="26" width="26"></td></tr></table><br><input type="button" id="bold" style="height:21px; width:21px; font-weight:bold;" value="G" onClick="fontEdit('bold')" title="Grassetto"/><input type="button" id="italic" style="height:21px; width:21px; font-style:italic;" value="C" onClick="fontEdit('italic')" title="Corsivo" /><input type="button" id="underline" style="height:21px; width:21px; text-decoration:underline;" value="S" onClick="fontEdit('underline')" title="Sottolineato" /> |<input type="button" style="height:21px; width:21px;"value="S" onClick="fontEdit('justifyleft')" title="Allinea a sinistra" /><input type="button" style="height:21px; width:21px;"value="C" onClick="fontEdit('justifycenter')" title="centrato" /><input type="button" style="height:21px; width:21px;"value="D" onClick="fontEdit('justifyright')" title="Allinea a destra" /> |<select id="fonts" onChange="fontEdit('fontname',this[this.selectedIndex].value)"><option value="Arial">Arial</option><option value="Comic Sans MS">Comic Sans MS</option><option value="Courier New">Courier New</option><option value="Monotype Corsiva">Monotype</option><option value="Tahoma">Tahoma</option><option value="Times">Times</option></select><select id="size" onChange="fontEdit('fontsize',this[this.selectedIndex].value)"><option value="1">8 pt</option><option value="2">10 pt</option><option value="3">12 pt</option><option value="4">14 pt</option><option value="5">16 pt</option><option value="6">18 pt</option><option value="7">20 pt</option></select><select id="color" onChange="fontEdit('ForeColor',this[this.selectedIndex].value)"><option value="black">Nero</option><option style="color:red;" value="red">Rosso</option><option style="color:blue;" value="blue">Blu</option><option style="color:green;" value="green">Verde</option><option style="color:#FF00FF;" value="pink">Rosa</option></select> |<input type="button" style="height:21px; width:21px;"value="1" onClick="fontEdit('insertorderedlist')" title="Elenco numerato" /><input type="button" style="height:21px; width:21px;"value="●" onClick="fontEdit('insertunorderedlist')" title="Elenco puntato" /><input type="button" style="height:21px; width:21px;"value="←" onClick="fontEdit('outdent')" title="Riduci rientro" /><input type="button" style="height:21px; width:21px;"value="→" onClick="fontEdit('indent')" title="Aumenta rientro" /></div><iframe id="textEditor" style="width:807px; height:427px;"></iframe></center><script type="text/javascript"><!--textEditor.document.designMode="on";textEditor.document.open();textEditor.document.write('<head><style type="text/css">body{ font-family:arial; font-size:13px; }</style> </head>');textEditor.document.close();function def(){document.getElementById("fonts").selectedIndex=0;document.getElementById("size").selectedIndex=1;document.getElementById("color").selectedIndex=0;}function fontEdit(x,y){textEditor.document.execCommand(x,"",y);textEditor.focus();}--></script></div><div id="firefoxerror"><p>Attenzione! Stai usando Mozilla Firefox che non è supportato dall Editor. L' Editor supporta Internet Explorer, Chrome, Opera e Safari.</p></div></body></html> Thank you, Best regards,Francesco
  12. hello w3s again... i have trouble again with a self project, and this time (like allways) i have no clue why it does this... 1. i have some files like so given in picture: ATTACHED now inside the bittorrent.php file, i have my whole site defined in functions like so: <?php/*=========================*/$mysql_host = "localhost";$mysql_user = "root";$mysql_pass = "daniel1";$mysql_db = "ss_2012";$db_details = mysql_connect($mysql_host, $mysql_user, $mysql_pass);mysql_select_db($mysql_db, $db_details)or die(mysql_error());/*=========================*/function stdhead($title = "",$css_file = ""){$stdhead_start .="<!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=iso-8859-1' /><link rel='stylesheet' type='text/css' href='styles/".$css_file.".css'/><link rel='shortcut icon' href='fav_icon.ico' /><title>".$title."</title></head><body>"; $stdhead_start .="<table class='banner_table' align='center' cellpadding='0'><tr><td><a href='index.php'><img src='styles/images/banners/banner.png' width='1000' height='140' alt='SS_2012' /></a></td></tr></table>"; $stdhead_start .="<table class='status_table' align='center'><tr><td class='status_left'>LEFT</td><td class='status_right'>RIGHT</td></tr></table>"; $stdhead_start .="<table class='menu_table' border='0' align='center'><tr><td class='navigation'><a href='index.php'>HOME</a></td><td class='navigation'><a href='browse.php'>BROWSE</a></td><td class='navigation'><a href='upload.php'>UPLOAD</a></td><td class='navigation'><a href='request.php'>REQUESTS</a></td><td class='navigation'><a href='chat.php'>CHAT</a></td><td class='navigation'><a href='forums.php'>FORUM</a></td><td class='navigation'><a href='guides.php'>GUIDES</a></td><td class='navigation'><a href='bonus.php'>BONUS</a></td><td class='navigation'><a href='rules.php'>RULES</a></td><td class='navigation'><a href='faq.php'>FAQ</a></td><td class='navigation'><a href='links.php'>LINKS</a></td><td class='navigation'><a href='support.php'>SUPPORT</a></td></tr></table>"; $stdhead_start .="<table class='main_table' align='center'><tr><td>";return $stdhead_start;}//stdhead ends... function stdfooter(){$stdfoot_start ="</td></tr></table> <table class='foot_table' align='center'> <tr> <td>Speed-Scene © 2012 -> Revision 01</td> </tr> </table> </body> </html>"; return $stdfoot_start;}//stdfooter ends... /*====================FUNCTIONS PLACE!...====================================*/ function tr($x,$y,$noesc=0) {if ($noesc) $a = $y;else { $a = htmlspecialchars($y); $a = str_replace("\n", "<br />\n", $a);}print("<tr><td class=\"heading\" valign=\"top\" align=\"right\">$x</td><td valign=\"top\" align=left>$a</td></tr>\n");} function genrelist() {$ret = array();$res = mysql_query("SELECT id, name FROM categories ORDER BY name");while ($row = mysql_fetch_array($res)) $ret[] = $row;return $ret;} function StatusBar(){echo "<table class='status_table' align='center'><tr><td class='status_left'>LEFT</td><td class='status_right'>RIGHT</td></tr></table>";}?> and when i replace the status bar place with the StatusBar() Function inside the head function, then i get this result here: http://speed-scene.c...wrong/login.php and when i have the normal text building writed inside the place, then i get the normal design as i wish it to be like this: http://speed-scene.c..._good/login.php now, what i am in a need of, is that if someone can explain me why the design is going to be screwed up with all stuff, the fonts size,the status over the banner, even when i have said to it that it should be under it... then its placing itself up there -.-'... and im calling the designs like so as a example on my login page: <?phprequire_once("include/bittorrent.php");echo stdhead("Login","1");?> This is the Login Page!... <?phpecho stdfooter();?> so now i have my final question here... what the heck am i doing wrong?... someone?... ideas?... EDIT: and no, im not trying to make a torrent tracker... just called the file bittorrent.php for that name because i was trying to follow a tutorial .. EDIT #2: Did i post the right place at all?... mean, should i post in css section instead? ...
  13. honkmaster

    php upload issue

    Hi looking for a bit of help, I'm trying to create an upload script that send file to a directory named in the form "uploads/images/$company" I'm not bothered if the dir already exists The issue I'm have is the uploaded files don't end up in the directory set by "$company" they end up in the "images level Any help or advice would be great, its driving me made Cheers Chris <?php //testing postecho "$_POST[nouploads]";echo "<br />";echo "$_POST[company]";//posted from form$nouploads = "$_POST[nouploads]";$company = "$_POST[company]";//make a dir with the same name as company//does not matter if it already existsif (!file_exists ( "uploads/image/$company" )) {mkdir("uploads/image/$company", 0777, true);}error_reporting(E_ALL); //directory to upload to $upload_dir= "uploads/image/$company"; //numver of files to upload passed by form $num_uploads = "$nouploads"; //maximum filesize allowed in bytes $max_file_size = 2000000; //the maximum filesize from php.ini $ini_max = str_replace('M', '', ini_get('upload_max_filesize')); $upload_max = $ini_max * 2000000; //a message for users $msg = 'Please select files for uploading'; //an array to hold messages $messages = array(); //check if a file has been submitted if(isset($_FILES['userfile']['tmp_name'])) { //loop through the array of files for($i=0; $i < count($_FILES['userfile']['tmp_name']);$i++) { //check if there is a file in the array if(!is_uploaded_file($_FILES['userfile']['tmp_name'][$i])) { $messages[] = 'No file uploaded'; } //check if the file is less then the max php.ini size elseif($_FILES['userfile']['size'][$i] > $upload_max) { $messages[] = "File size exceeds $upload_max php.ini limit"; } //check the file is less than the maximum file size elseif($_FILES['userfile']['size'][$i] > $max_file_size) { $messages[] = "File size exceeds $max_file_size limit"; } else { //copy the file to the specified dir if(@copy($_FILES['userfile']['tmp_name'][$i],$upload_dir.'/'.$_FILES['userfile']['name'][$i])) { //give praise and thanks to the php gods $messages[] = $_FILES['userfile']['name'][$i].' uploaded'; } else { //an error message $messages[] = 'Uploading '.$_FILES['userfile']['name'][$i].' Failed'; } } } }?><!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" xml:lang="en" lang="en"><head><title>Multiple File Upload</title></head><body><h3><?php echo $msg; ?></h3><p><?php if(sizeof($messages) != 0) { foreach($messages as $err) { echo $err.'<br />'; } }?></p><form enctype="multipart/form-data" action="upload3.php" method="post"><input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_file_size; ?>" /><?php $num = 0; while($num < $num_uploads) { echo '<div><input name="userfile[]" type="file" /></div>'; $num++; }?><input type="submit" value="Upload" /></form></body></html>
  14. hello w3schools again, i just have a question this time .today i was trying to adding a upload script to my personal website . by following this tutorial: http://www.w3schools.com/php/php_file_upload.asp so here is my question.if im doing the saving part ''with'' the restrictions on it. what is the syntax for uploading a .torrent/.php/.html/ect file... i mean, before a filetype, there is somfthing that needs to be typed, like now, (image) ect...what is the syntax for making the part of a PHP and TORRENT file. thanks in advance.Hoping answers soon.
  15. Identical Comparison Operator: ===It compares the value and the type. I created a cookie and the value I used was 0. I compared it like this "if($_COOKIE['value']===0){ echo 'EQUAL';}". It seems to not be the same. Can anyone explain to me why? Aren't they both like integers?
  16. FeverZebra

    Realtime form

    Hello there. I've been trying to find useful information with google but I'm not sure what I should look for hence I've failed... Is it possible to make a form which gives results right away, without a "submit" button? Say for instance:34*X=Y X is the value you put into the "form inputbox".Y is the result. If I type 10, then klick another box then I want Y to become 340 without having to push a submit/calculate button. Is this possible? At the moment I've a form and a script on the same page. However, I've to push submit to se the results. When I submit the form is reseted. If I can't make a "realtime script" then can I have the form NOT reseting when I submit? Thanks a bunch, and sorry if I've posted in the wrong category!/W
  17. Does setcookie work after the script stops? When I make my script print the cookie after I set it, I get a notice saying it is undefined. If I run another script to print the cookies after the script that sets it, it works fine.
  18. <html><!--php_json.php--><head><script src="json2.js"></script><script src="php.js"></script><script>ajax("php_json.json",function(){oJSON = JSON.parse(xmlhttp.responseText);sJSON = JSON.stringify(oJSON);/*put it hereokay*/});// here, the variable sJSON is undefinedajax("php.php?json="+sJSON,function(){ alert(xmlhttp.responseText); });//</script></head><body></body></html> // php.jsfunction ajax(source,func){xmlhttp = (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP") ? new ActiveXObject("Msxml2.XMLHTTP") : null ;xmlhttp.onreadystatechange = function(){ (xmlhttp.readyState == 4 && xmlhttp.status == 200) ? func() : null ; }xmlhttp.open("GET",source,true);xmlhttp.send();} wanna ask how to extend the scope of the variable sJSON to be global?
  19. dalawh

    Writing into a file

    I was wondering if there was any way to set a file to write to beginning? It seems I am only allowed to do one or the other. Is there an alternative to this?
  20. sunziun

    PHP Min Max

    Hello Everyone, right now I am trying to do an small app that can calculate fees based on the price a user has given. Example: $0.01 - $0.99 = $0.09$1 - $5.99 = $0.13$99 or more = $1.34 So far I have this code but I cannot get it to work properly: if($start < 1.00){ echo "<p>" . $ins_fees[0] . $sym . $ins_fees[1] . "</p>"; // FURTHER CALCULATION } if($start == 1.00){ echo "<p>" . $ins_fees[0] . $sym . $ins_fees[2] . "</p>"; // FURTHER CALCULATION } else{ if($start > 1){ echo "<p>" . $ins_fees[0] . $sym . $ins_fees[2] . "</p>"; // FURTHER CALCULATION } } thanks for everyone!
  21. I would like to use PHP to put a vertical space on a web page. echo "<br \><br \><br \><br \>"; works fine on FireFox but probably breaks several rules in relation to strict xhtml and may not work as well on other browsers. Is there are more standard/correct/robust way of doing this? Thanks,Peter.
  22. Hello there, I have developed this piece of php/html code, for my custom Wordpress theme. <?php get_header(); ?><div class="layout clearfix"> <div id="content"> <?php if (have_posts()) : ?> <div id="loops-wrapper" class="left"> <?php while (have_posts()) : the_post(); ?> <div id="article-<?php the_id(); ?>" class="article clearfix"> <div class="post-others-wrap"> <p class="categories"><?php the_category('<br />'); ?></p> <div class="khmedia-social"> <p class='st_facebook_vcount' displayText='Facebook'></p> <p class='st_twitter_vcount' displayText='Tweet'></p> <p class='st_email_vcount' displayText='Email'></p> </div> </div> <div class="post-date-wrap"> <p class="post-date"> <span class="day"><?php the_time('d'); ?></span> <span class="month"><?php the_time('M'); ?></span> <span class="year"><?php the_time('Y'); ?></span> </p> </div> <div id="article-title-<?php the_id(); ?>" class="post-title"> <h1> <?php echo the_title(); ?> </h1> <div id="article-excerpt-<?php the_id(); ?>" class="post-content"> <?php wp_link_pages( array( 'before' => '<div class="pages">'.'पृष्ठ:', 'after' => '</div>' ) ); ?> <?php the_content(); ?> <?php wp_link_pages( array( 'before' => '<div class="pages">'.'पृष्ठ:', 'after' => '</div>' ) ); ?> </div> </div> </div> <?php endwhile; ?> <div id="pagelinks" class="clearfix"> <?php previous_post_link('<div class="prevlink">%link</div>'); ?> <?php next_post_link('<div class="nextlink">%link</div>'); ?> </div> </div> <?php endif; ?> </div> <div class="sidebar"> <?php if ( is_active_sidebar( 'primary' ) ) : dynamic_sidebar( 'primary' ); endif; ?> </div></div><?php get_footer(); ?> And now here is the CSS for it: .layout { display: block; margin-top: 3em; width: 100%;} #content { line-height: 1.5em; width: 697px; float: left; padding-right: 30px; position: relative; min-height: 300px;} .clearfix { clear: both; content: " "; display: block; line-height: 0; visibility: inherit;} #loops-wrapper { display: block;} #loops-wrapper .article { padding-left: 122px; width: 600px; margin-bottom: 50px; min-height: 150px; display: block; position: relative;} #loops-wrapper .article .post-others-wrap { left: 0; display: block; position: absolute; width: 100px; margin: 55px 0 0; text-align: right; line-height: 1.5em;} #loops-wrapper .article .post-others-wrap .khmedia-social { display: block; border-top: 2px solid #8AE234; border-bottom: 2px solid #8ae234; padding: 0 0 5px; margin-top: 20px;} #loops-wrapper .article .post-others-wrap .categories { color: black; position: relative;} Actually, the main content area is expanding with large data. But, when I insert a simple post with only the title. The div is overlapping with the footer.Here is my site link: http://www.khmedia.in Please help guys...
  23. yoyo w3s...a question is needed to be answered... i have lately readed a little on to cakePHP... but i would like to know, if any in here think its better then normal PHP. and if so, then can anyone help me a little here?... because im trying to build up a design in it, so that an another coder from my mentor team online at ''World Wide Web'' ^^', can code the functionality to it... ideas?...and yes, i have downloaded latest version, just how to use it... i have tried to build up the simple blog at their main website, but it was a ###### without equal... that is why im asking here, when i now did not got my question in that tutorial answered... so... please answer ^^'...
  24. I been trying ti figure this out for a few hours now and I can't seem to figure it out. Hopefully, someone will be able to solve my dilemma. The error I get is "Fatal error: Cannot redeclare getDate() in C:\xampp\htdocs\dalawh\date.php on line 4" test.php <?phprequire 'date.php';$data=$last.' | '.$first.' | '.getDate().' | '.$_SERVER['SCRIPT_FILENAME'];echo $data;?> date.php <?phpfunction getDate(){echo date("l, M j, Y g:i:s A T");}?> When I comment out "require 'date.php'", everything works fine, but of course getDate() returns nothing. So I figured it had to do with that line. I thought it may have been the echo in date.php, so I tried return, but I still got the same error.
  25. When I am coding in a php file (.php extension), is it better to reduce the php area to as small as possible (like in the first case) or does it not matter (like the second case)? <html><body><?php//Some php code?></body></html> OR <?php<html><body>//Some php code</body></html>?>
×
×
  • Create New...