PHP - Please Clear My Doubt
Friends,
suppose iam copying 1 to 100 files using a loop in php & when the copy process reach at 50th file my browser went offline. My doubt is will it copy all 100 files ?? OR it will terminate at 50th file ? if i want to get all files copied if the browser went offline then what i want to do ?? Please clear Similar Tutorialswhats the diff between echo,print,print_r what's the difference between include(),require,require_once I am trying to run tests on my pages and see how much time each one of em take to execute. For this purpose, i'm using this code which i got online: Code: [Select] <?php $mtime = microtime(); $mtime = explode(" ",$mtime); $mtime = $mtime[1] + $mtime[0]; $starttime = $mtime; ?> <!-- Rest of the php and validation and form elements --> <?php $mtime = microtime(); $mtime = explode(" ",$mtime); $mtime = $mtime[1] + $mtime[0]; $endtime = $mtime; $totaltime = ($endtime - $starttime); echo "This page was created in ".$totaltime." seconds"; ?> microtime() returns microseconds & secs since Unix epoch. So after exploding, why do we add them both? Cant we just use the microseconds part? I've tried this code & the one above & both return same time(almost). Code: [Select] <?php $mtime = microtime(); $mtime = explode(" ",$mtime); $mtime = $mtime[0]; $starttime = $mtime; ?> <!-- Rest of the php and validation and form elements --> <?php $mtime = microtime(); $mtime = explode(" ",$mtime); $mtime = $mtime[0]; $endtime = $mtime; $totaltime = ($endtime - $starttime); echo "This page was created in ".$totaltime." seconds"; ?> Hi All, being a noob when it comes to any sort of coding I am facing a strong learning curve but I'm getting there. With the implementation of our new client portal, we require a new client sign-up api...The following was provided... <?php ////////////////////////////////////////////////////// // THIS CODE IS PROVIDED AS AN EXAMPLE OF HOW TO // USE THE DITTO PORTAL FOR AHSAY API'S. ////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////// // SET API VARIABLES ///////////////////////////////////////////////////////////////// //SET CUSTOMER ID AND API KEY $customerID = '8000003'; $key = '6NbTmZw5LZdtTO8FuYH9G'; //IF POSTBACK if ($_SERVER['REQUEST_METHOD'] == 'POST') { ///////////////////////////////////////////////////////////////// // GET VALUES FROM FORM ///////////////////////////////////////////////////////////////// $company = $_REQUEST['company']; $address1 = $_REQUEST['address1']; $address2 = $_REQUEST['address2']; $city = $_REQUEST['city']; $state = $_REQUEST['state']; $postal = $_REQUEST['postal']; $country = $_REQUEST['country']; $firstname = $_REQUEST['firstname']; $lastname = $_REQUEST['lastname']; $phone = $_REQUEST['phone']; $email = $_REQUEST['email']; $type = $_REQUEST['type']; $username = $_REQUEST['username']; $alias = $_REQUEST['alias']; $language = $_REQUEST['language']; $timezone = $_REQUEST['timezone']; ///////////////////////////////////////////////////////////////// // INVOKE LIST COUNTRIES API TO POPULATE COUNTRY DROP DOWN LIST ///////////////////////////////////////////////////////////////// //BUILD URL FOR API CALL $function = 'ListCountries'; $url = 'https://api.web-portal.co/?customerID=8000003&key=6NbTmZw5LZdtTO8FuYH9G&function=ListCountries'; //MAKE API CALL USING SIMPLE XML $countrylist = simplexml_load_file($url); foreach ($countrylist as $c) { if ($country == $c->countryID) { $countryOptions.="<OPTION VALUE=\"".$c->countryID."\" selected>".$c->countryName.""; } else { $countryOptions.="<OPTION VALUE=\"".$c->countryID."\">".$c->countryName.""; } } ///////////////////////////////////////////////////////////////// // INVOKE LIST LANGUAGES API TO POPULATE LANGUAGE DROP DOWN LIST ///////////////////////////////////////////////////////////////// //BUILD URL FOR API CALL $function = 'ListLanguages'; $url = 'https://api.web-portal.co/?customerID=8000003&key=6NbTmZw5LZdtTO8FuYH9G&function=ListLanguages'; //MAKE API CALL USING SIMPLE XML $languagelist = simplexml_load_file($url); foreach ($languagelist as $l) { if ($language == $l->languageID) { $languageOptions.="<OPTION VALUE=\"".$l->languageID."\" selected>".$l->languageName.""; } else { $languageOptions.="<OPTION VALUE=\"".$l->languageID."\">".$l->languageName.""; } } ///////////////////////////////////////////////////////////////// // INVOKE LIST TIMEZONES API TO POPULATE TIMEZONE DROP DOWN LIST ///////////////////////////////////////////////////////////////// //BUILD URL FOR API CALL $function = 'ListTimezones'; $url = 'https://api.web-portal.co/?customerID=8000003&key=6NbTmZw5LZdtTO8FuYH9G&function=ListTimezones'; //MAKE API CALL USING SIMPLE XML $timezonelist = simplexml_load_file($url); foreach ($timezonelist as $t) { if ($timezone == $t->timezoneID) { $timezoneOptions.="<OPTION VALUE=\"".$t->timezoneID."\" selected>".$t->timezoneName.""; } else { $timezoneOptions.="<OPTION VALUE=\"".$t->timezoneID."\">".$t->timezoneName.""; } } ///////////////////////////////////////////////////////////////// // BEFORE CALLING THE ADDCLIENT API, YOU SHOULD VALIDATE THE // USER'S INPUT (ALL REQUIRED FIELDS COMPLETE, EMAIL ADDRESS // ETC. ///////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////// // INVOKE ADD CLIENT API TO ACTIVATE ACCOUNT ///////////////////////////////////////////////////////////////// //SET ACCOUNT TYPE AND TRIAL LENGTH $account = 'TRIAL'; $length = '14'; //BUILD URL FOR API CALL $function = 'AddClient'; $url = 'https://api.web-portal.co/?'. "customerID=".$customerID. "&key=".$key. "&function=".$function. "&company=".$company. "&address1=".$address1. "&address2=".$address2. "&city=".$city. "&state=".$state. "&postal=".$postal. "&country=".$country. "&firstname=".$firstname. "&lastname=".$lastname. "&phone=".$phone. "&email=".$email. "&type=".$type. "&username=".$username. "&alias=".$alias. "&language=".$language. "&timezone=".$timezone. "&account=".$account. "&length=".$length; //MAKE API CALL USING SIMPLE XML $createClient = simplexml_load_file($url); //DISPLAY RESULTS OF API CALL echo $createClient; } //NOT POSTBACK else { ///////////////////////////////////////////////////////////////// // INVOKE LIST COUNTRIES API TO POPULATE COUNTRY DROP DOWN LIST ///////////////////////////////////////////////////////////////// //BUILD URL FOR API CALL $function = 'ListCountries'; $url = 'https://api.web-portal.co/?customerID=8000003&key=6NbTmZw5LZdtTO8FuYH9G&function=ListCountries'; //MAKE API CALL USING SIMPLE XML $countrylist = simplexml_load_file($url); foreach ($countrylist as $c) { $countryOptions.="<OPTION VALUE=\"".$c->countryID."\">".$c->countryName.""; } ///////////////////////////////////////////////////////////////// // INVOKE LIST LANGUAGES API TO POPULATE LANGUAGE DROP DOWN LIST ///////////////////////////////////////////////////////////////// //BUILD URL FOR API CALL $function = 'ListLanguages'; $url = 'https://api.web-portal.co/?customerID=8000003&key=6NbTmZw5LZdtTO8FuYH9G&function=ListLanguages'; //MAKE API CALL USING SIMPLE XML $languagelist = simplexml_load_file($url); foreach ($languagelist as $l) { $languageOptions.="<OPTION VALUE=\"".$l->languageID."\">".$l->languageName.""; } ///////////////////////////////////////////////////////////////// // INVOKE LIST TIMEZONES API TO POPULATE TIMEZONE DROP DOWN LIST ///////////////////////////////////////////////////////////////// //BUILD URL FOR API CALL $function = 'ListTimezones'; $url = 'https://api.web-portal.co/?customerID=8000003&key=6NbTmZw5LZdtTO8FuYH9G&function=ListTimezones'; //MAKE API CALL USING SIMPLE XML $timezonelist = simplexml_load_file($url); foreach ($timezonelist as $t) { $timezoneOptions.="<OPTION VALUE=\"".$t->timezoneID."\">".$t->timezoneName.""; } } ?> <!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>Untitled Document</title> </head> <body> <p>NEW CLIENT SIGN UP</p> <form id="NewClientForm" name="NewClientForm" method="post" action="NewClientForm.php"> <p>Company Name:<br /> <label for="company"></label> <input type="text" name="company" id="company" value="<? echo $company; ?>" /> </p> <p>Address 1:<br /> <label for="address1"></label> <input type="text" name="address1" id="address1" value="<? echo $address1; ?>" /> </p> <p>Address 2:<br /> <label for="address2"></label> <input type="text" name="address2" id="address2" value="<? echo $address2; ?>" /> </p> <p>City:<br /> <label for="city"></label> <input type="text" name="city" id="city" value="<? echo $city; ?>" /> </p> <p>State/Province:<br /> <label for="state"></label> <input type="text" name="state" id="state" value="<? echo $state; ?>" /> </p> <p>Zip/Postal Code:<br /> <label for="postal"></label> <input type="text" name="postal" id="postal" value="<? echo $postal; ?>" /> </p> <p>Country:<br /> <label for="country"></label> <select name="country" id="country"> <? echo $countryOptions; ?> </select> </p> <p>Primary Contact First Name:<br /> <label for="firstname"></label> <input type="text" name="firstname" id="firstname" value="<? echo $firstname; ?>" /> </p> <p>Primary Contact Last Name:<br /> <label for="lastname"></label> <input type="text" name="lastname" id="lastname" value="<? echo $lastname; ?>" /> </p> <p>Primary Contact Telephone:<br /> <label for="phone"></label> <input type="text" name="phone" id="phone" value="<? echo $phone; ?>" /> </p> <p>Primary Contact Email:<br /> <label for="email"></label> <input type="text" name="email" id="email" value="<? echo $email; ?>" /> </p> <p>Account Type:<br /> <input type="radio" name="type" id="acb" value="ACB" /> <label for="acb">ACB</label> <input type="radio" name="type" id="obm" value="OBM" /> <label for="obm">OBM</label> </p> <p>Preferred Username:<br /> <label for="username"></label> <input type="text" name="username" id="username" value="<? echo $username; ?>" /> </p> <p>Alias/Nickname:<br /> <label for="alias"></label> <input type="text" name="alias" id="alias" value="<? echo $alias; ?>" /> </p> <p>Language:<br /> <label for="language"></label> <select name="language" id="language"> <? echo $languageOptions; ?> </select> </p> <p>Timezone:<br /> <label for="timezone"></label> <select name="timezone" id="timezone"> <? echo $timezoneOptions; ?> </select> </p> <p> </p> <p> <input type="submit" name="submit" id="submit" value="Sign Up" /> </p> </form> <p><br /> </p> </body> </html> The following errors are produced... http://cubetech.com.au/downloads/signup.php Can please confirm my suspicions of simplexml_load_file() are not permitted. I have been reading about cURL implementation instead can someone provide some assistance if this is possible and assist. A lot of thank in advance, Andrew Chapman Hi all, Can anyone offer assistance with the following: I am trying to obtain a score from a users radio button selection on a simple quiz. i am not able to obtain the results.... I'm not sure if this is exactly a coding help question, excuse me if its not. I want to know what is the best & secure way to submit a form to itself. I've tried to google the answer, but did not get a proper answer with explanation or may be I didnt use proper keywords to search it. Out of these which one do i use? Code: [Select] // Leave the action field empty. <form method="POST" action=""> //$PHP_SELF, also if i use echo $PHP_SELF my form does not work like it should. <form method="POST" action="<?$PHP_SELF?>"> //$_SERVER['PHP_SELF'], same problem as $PHP_SELF, it doesnt work if i use echo. <form method="POST" action="<?$_SERVER['PHP_SELF']?>"> Hello guys, i need to create a code for making connections with SSL servers (particularly SMTPS and POP3S) and i know about the existence of OpenSSL extension. However, i'm in doubt about a basic issue: 1. Is this extension useful for creating SSL clients or SSL servers? I'm not a SSL expert, so maybe i'm misunderstanding something; i hope you can help me. Kind regards. I have a php code that call a process (a java program). The process runs in background for a so long time - from 1 minute to 2 hours. I make the process call using exec:
<?php function execInBackground($cmd) { if (substr(php_uname(), 0, 7) == "Windows"){ pclose(popen("start /B ". $cmd, "r")); } else { exec($cmd . " &> /dev/null &"); } } $command = "java ... ReadEmailsCmdLine 2>&1"; execInBackground($command); echo "FINALIZADO";Though the command runs in background it looks that the PHP code wait for the command completion to send a answer to client browser because I just see "FINALIZADO" after the java program finished its execution. Does someone know how I can solve this problem? Or at least does have a hint/pointer for that? Since now I thanks any comment/suggestion Hi All, I am developing PHP website. In my initial stage I wanted to accept some information from user... after that I wanted to display that information in different div but on same page... Lets say My page is having two div tags. First div for simple HTML form which will help user to enter data, second div to display info entered by user. I am doing this because I wanted to hide second div until user enter info into form and hit submit button. Its working fine when page load first time. second div is hidden, user add info and hit submit button then second div comes with info added by user. But when i refresh, its showing second div with previous info. As I am new to php and javascript I am not sure what to do.. Let me knw if some have any idea to solve this, Thanks in advance. This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=356851.0 I was wondering if anyone knows a way where you can submit a form but content of the input fields will not be cleared? The reason why I want to achieve this effect is because I have a form and I want to user to be able to preview the results before properly submitting the form. Therefore I will have two submit buttons, one to preview and one to submit. Thanks for any help. index.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" > <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-language" content="en" /> <link type="text/css" rel="stylesheet" href="css/reset.css" /> <link type="text/css" rel="stylesheet" href="css/960.css" /> <link type="text/css" rel="stylesheet" href="css/custom.css" /> <title>BAY AREA REMOTE CONTROL SOCIETY</title> </head> <body> <div id="wrapper" class="container_12"> <div id="header" class="grid_12"> <div id="left-header" class="grid_5 alpha"></div> <div id="newsflash" class="grid_7 omega"><?php include('content/newsflash.php'); ?></div> </div> <div id="leftmenu" class="grid_3"><?php include('content/menu.php'); ?></div> <div id="maincontent" class="grid_9"><?php include('content/maincontent.php'); ?></div> <div id ="footer" class="grid_12"><?php include('content/footer.php'); ?></div> </div><!-- end wrapper --> </body> </html> menu.php <?php ?> <div class="content"> <ul id="menu"> <li><a href="index.php?page=testpage"><span>Home</span></a></li> <li><a href="index.php?page=about"><span>About us</span></a></li> <li><a href="index.php?page=schedule"><span>Schedule</span></a></li> <li><a href="index.php?page=media"><span>Media</span></a></li> <li><a href="index.php?page=products"><span>Products</span></a></li> <li><a href="index.php?page=misc"><span>Miscellaneous</span></a></li> </ul> </div> When I click HOME on the Menu program it works fine but it does not clear the content of maincontent.php. How do I do that? Hi: I am using this code for my contact us feedback form: Code: [Select] <?php $error = NULL; $myDate = NULL; $FullName = NULL; $Address = NULL; $City = NULL; $State = NULL; $Zip = NULL; $Phone = NULL; $Email = NULL; $Website = NULL; $Comments = NULL; if(isset($_POST['submit'])) { $myDate = $_POST['myDate']; $FullName = $_POST['FullName']; $Address = $_POST['Address']; $City = $_POST['City']; $State = $_POST['State']; $Zip = $_POST['Zip']; $Phone = $_POST['Phone']; $Email = $_POST['Email']; $Website = $_POST['Website']; $Comments = $_POST['Comments']; if(empty($FullName)) { $error .= '-- Enter your Full Name. <br />'; } if(empty($Email)) { $error .= '-- Enter your Email. <br />'; } if($error == NULL) { $sql = sprintf("INSERT INTO myContactData(myDate,FullName,Address,City,State,Zip,Phone,Email,Website,Comments) VALUES ('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')", mysql_real_escape_string($myDate), mysql_real_escape_string($FullName), mysql_real_escape_string($Address), mysql_real_escape_string($City), mysql_real_escape_string($State), mysql_real_escape_string($Zip), mysql_real_escape_string($Phone), mysql_real_escape_string($Email), mysql_real_escape_string($Website), mysql_real_escape_string($Comments)); if(mysql_query($sql)) { $error .= 'Thank you for contacting us.'; mail( "d@direct.com", "Contact Request", "Date Sent: $myDate\n Full Name: $FullName\n Address: $Address\n City: $City\n State: $State\n Zip: $Zip\n Phone: $Phone\n Email: $Email\n Website: $Website\n Comments: $Comments\n", "From: $Email" ); } else { $error .= 'There was an error in our Database, please Try again!'; } } } echo '<span class="textError">' . $error . '</span>'; ?> <form name="myform" action="" method="post"> <input type="hidden" name="myDate" size="45" maxlength="50" value="<?php echo date("F j, Y"); ?>" /> <div id="tableFormDiv"> <fieldset><span class="floatLeftFormWidth"><span class="textErrorItalic">* - Required</span></span> <span class="floatFormLeft"> </span></fieldset> <fieldset><span class="floatLeftFormWidth"><span class="textErrorItalic">*</span> Full Name:</span> <span class="floatFormLeft"><input type="text" name="FullName" size="45" maxlength="50" value="<?php echo $FullName; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth">Address:</span> <span class="floatFormLeft"><input type="text" name="Address" size="45" maxlength="50" value="<?php echo $Address; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth">City:</span> <span class="floatFormLeft"><input type="text" name="City" size="45" maxlength="50" value="<?php echo $City; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth">State:</span> <span class="floatFormLeft"><input type="text" name="State" size="45" maxlength="50" value="<?php echo $State; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth">Zip:</span> <span class="floatFormLeft"><input type="text" name="Zip" size="45" maxlength="50" value="<?php echo $Zip; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth">Phone:</span> <span class="floatFormLeft"><input type="text" name="Phone" size="45" maxlength="50" value="<?php echo $Phone; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth"><span class="textErrorItalic">*</span> Email:</span> <span class="floatFormLeft"><input type="text" name="Email" size="45" maxlength="50" value="<?php echo $Email; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth">Website:</span> <span class="floatFormLeft"><input type="text" name="Website" size="45" maxlength="50" value="<?php echo $Website; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth">Comments:</span> <span class="floatFormLeft"><textarea name="Comments" cols="40" rows="10"><?php echo $Comments; ?></textarea></span></fieldset> </div> <input type="submit" name="submit" value="Submit" class="submitButton" /><br /> </form> I the only thing I can't figure out is, how do I clear the form fields AFTER the form has been submitted and the message "Thank you for contacting us." appears ?? I haven't been able to figure it out with JavaScript/PHP, so I posted my original code in hopes that someone will have an idea. Anyone? Thanks! Is there any way to have html output and then clear the output to allow for headers to be changed? This is still while the php file is executing. The reason I ask is that I am trying to output a progress bar of an excel file being created. So while the file is being created by php, I want to output to the browser a progress bar and then once it is complete, I need to set headers so that it downloads it as an excel file. Is this possible or does anyone else have any ideas? Should I maybe save the file on the web server temporarily and then redirect to the file afterwards? Any help would be appreciated. Thanks, -JC What is the PROPER way to clear out an array? I have an array getting created as part of a loop process, and for each loop, I want the array to be emptied and start from scratch? I googled it and see some ways but the people offering the solutions don't seem too sure of themselves, so I just want to know if there is one, widely accepted and proper/efficient way to do this? Hi all, I have a table... id | Name | Downloads | 01 | tom | 5 02 | thomas | 2 03 | tommy | 15 I need a button in my page whcih on submit would resent the 'downloads' column so all values are set to 0, Is this possible and how if it is? Thanks for any advice So I have a page that has profile images basically, but these images cache and when someone clicks on anything, like rotate image, since my script rotates the image and saves it correctly, I can hit Ctrl+F5 and the image then shows up correct, but the page loading itself after running my script using a get method and then using the header coming back to the same page the image looks like it wasn't reloaded. Noones gonna hit Ctrl+F5, so how do I get this to cache the image completely when the page reloads? I've tried <meta http-equiv="pragma" content="no-cache" /> But this doesn't work, well nothing seems to work really. In drive.php
public function insert($postBody, $optParams = array()) |