PHP - Changing Imput Type On A Form
I changed the imput type on a registration form from type="submit" to type="image" and the warning messages don't show here is the code
Code: [Select] [<?php include "includes/config.php"; include "includes/functions.php"; session_start(); ob_start(); $name=trim($_REQUEST['name']); $company=trim($_REQUEST['company']); $phone=trim($_REQUEST['phone']); $email=trim($_REQUEST['email']); $address=trim($_REQUEST['address']); $city=trim($_REQUEST['city']); $state=trim($_REQUEST['state']); $zipcode=trim($_REQUEST['zipcode']); $loginid=trim($_REQUEST['loginid']); $password=trim($_REQUEST['pw1']); $confirmpassword=trim($_REQUEST['pw2']); if(isset($_REQUEST['Submit'])) { if($password==$confirmpassword) { if( $_SESSION['security_code'] == $_POST['security_code'] && !empty($_SESSION['security_code'] ) ) { if(mysql_num_rows(mysql_query("SELECT * FROM `tbl_registration` WHERE `loginid` = '".$loginid."'")) == 0) { $sqlregister = "INSERT INTO `tbl_registration`(`name`,`company`,`phone`,`email`,`address`,`city`,`state`,`zip`,`loginid`,`password`) VALUES ('".$name."','".$company."','".$phone."','".$email."','".$address."','".$city."','".$state."','".$zipcode."','".$loginid."','".$password."') "; $rsregister= mysql_query($sqlregister); //$num=mysql_num_rows($rssearch); /*$rowArr=array(); $rowResult=array(); */ $Msg=message("You Have Registered Successfully..",2); if(is_dir("upload/".$loginid)) $msg1 = message("Problem With Creating Account.!",2); else { mkdir("upload/".$loginid); mkdir("upload/".$loginid."/web"); mkdir("upload/".$loginid."/email"); mkdir("upload/".$loginid."/emaildata"); } } else $msg = message("Login Id already exists..try another.!",2); } else { $msg =message("Sorry, you have provided an invalid security code.!",2); } } else $msg = message("confirm password does not match.!",2); } ?>/code] the form [code]<form name="form1" action="your_info.php" method="post" onSubmit="return validate(form1);"> <table width='360' cellpadding='1' cellspacing='2' bordercolor='#CACEDA' class="borders" align="center"> <tr> <td></td> <td colspan="3" class="txt3"><span style="padding-left:35px;"> <?=$Msg;?><br><?=$msg;?><br><?=$msg1;?> </span></td> </tr> <tr> <td width="16"></td> <td width="100" class="txt3"><div align="right">Name:</div></td> <td width="200"><input name="name" type="text" size="40" class="ordertextin" value="<?=$name;?>"></td> <td width="20"></td> </tr> <tr> <td width="16"></td> <td width="100" class="txt3"><div align="right">Company:</div></td> <td width="200"><input name="company" type="text" size="40" class="ordertextin" value="<?=$company;?>"></td> <td width="20"></td> </tr> <tr> <td width="16"></td> <td width="100" class="txt3"><div align="right">Phone:</div></td> <td width="200"><input name="phone" type="text" size="40" class="ordertextin" value="<?=$phone;?>"></td> <td width="20"></td> </tr> <tr> <td width="16"></td> <td class="txt3" width="100"><div align="right">Email:</div></td> <td><input name="email" type="text" size="40" class="ordertextin" value="<?=$email;?>"></td> <td width="20"></td> </tr> <tr> <td width="16"></td> <td width="100" class="txt3"><div align="right">Address:</div></td> <td width="200"><input name="address" type="text" size="40" class="ordertextin" value="<?=$address;?>"></td> <td width="20"></td> </tr> <tr> <td width="16"></td> <td width="100" class="txt3"><div align="right">City:</div></td> <td width="200"><input name="city" type="text" size="30" class="ordertextin" value="<?=$city;?>"></td> <td width="20"></td> </tr> <tr> <td width="16"></td> <td width="100"> <div align="right"><span class="txt3">State:</span></div></td> <td width="200" align="left"> <select name="state" class="ordertextin"> <option selected>Choose one </option> <option value="AL">Alabama</option> <option value="AK">Alaska</option> <option value="AZ">Arizona</option> <option value="AR">Arkansas</option> <option value="CA">California</option> <option value="CO">Colorado</option> <option value="CT">Connecticut</option> <option value="DE">Delaware</option> <option value="FL">Florida</option> <option value="GA">Georgia</option> <option value="GU">Guam</option> <option value="HI">Hawaii</option> <option value="ID">Idaho</option> <option value="IL">Illinois</option> <option value="IN">Indiana</option> <option value="IA">Iowa</option> <option value="KS">Kansas</option> <option value="KY">Kentucky</option> <option value="LA">Lousiana</option> <option value="ME">Maine</option> <option value="MD">Maryland</option> <option value="MA">Massachusetts</option> <option value="MI">Michigan</option> <option value="MN">Minnesota</option> <option value="MS">Mississippi</option> <option value="MO">Missouri</option> <option value="MT">Montana</option> <option value="NE">Nebrasca</option> <option value="NV">Nevada</option> <option value="NB">New Brunswick</option> <option value="NH">New Hamshire</option> <option value="NJ">New Jersey</option> <option value="NM">New Mexico</option> <option value="NY">New York</option> <option value="NC">North Carolina</option> <option value="ND">North Dakota</option> <option value="OH">Ohio</option> <option value="OK">Oklahoma</option> <option value="OR">Oregon</option> <option value="OTHER">Other</option> <option value="PA">Pennsylvania</option> <option value="PR">Puerto Rico</option> <option value="RI">Rhode Island</option> <option value="SC">South Carolina</option> <option value="SD">South Dakota</option> <option value="TN">Tennessee</option> <option value="TX">Texas</option> <option value="UT">Utah</option> <option value="VT">Vermont</option> <option value="VI">Virgin Islands</option> <option value="VA">Virginia</option> <option value="WA">Washington</option> <option value="DC">Washington DC</option> <option value="WI">Wisconsin</option> <option value="WY">Wyoming</option> <option value="YK">Yukon</option> </select> </td> <td width="20"></td> </tr> <tr> <td width="16"></td> <td width="100" class="txt3"><div align="right">Zip:</div></td> <td width="200"><input name="zipcode" type="text" size="30" class="ordertextin" value="<?=$zipcode;?>"></td> <td width="20"></td> </tr> <tr> <td></td> <td class="txt3" width="100"><div align="right">Login Id: </div></td> <td><input name="loginid" type="text" size="30" class="ordertextin" value="<?=$loginid;?>"></td> <td></td> </tr> <tr> <td width="16"></td> <td class="txt3" width="100"><div align="right">Password:</div></td> <td><input name="pw1" type="password" size="40" class="ordertextin" value="<?=$password;?>"></td> <td width="20"></td> </tr> <tr> <td width="16"></td> <td class="txt3"><div align="right">Confirm Password: </div></td> <td><input name="pw2" type="password" size="40" class="ordertextin" value="<?=$confirmpassword;?>"></td> <td width="20"></td> </tr> <tr> <td height="10"></td> <td><div align="right">Security Code: </div></td> <td><img src="CaptchaSecurityImages.php?width=150&height=28&characters=7"/><br/><input id="security_code" name="security_code" type="text" class="inputType Inputsize150"/></td> </tr> <tr> <td width="16"></td> <td></td> <td> </td> <td width="20"></td> </tr> <tr><td height="20"></td> <td></td> <td><DIV class=satisfaction-quarantee-image-alignment ><INPUT type="image" name="Submit" height=54 alt="submit" width=208 src="images/submit_butom.gif"></DIV></td> </tr> </table> </form> Thanks. Similar Tutorials<?php require_once('init.php'); $results = $db->prepare('SELECT file_location, file_type, file_size, id as media_id WHERE id = ? LIMIT 1;'); $results->execute(array($_GET['id'])); while ($row = $results->fetch()) { header('Content-Type: ' . $row['file_type']); header('Content-Length: ' . $row['file_size']); $media_ins = $db->prepare('UPDATE media SET total_clicks = total_clicks + 1 WHERE id = ?'); $media_ins->execute(array($row['id'])); readfile($row['file_location']); }For some reason, putting the header('Content-Type....') causes the UPDATE statement to trigger twice increasing the total_clicks by 2. Commenting out the content-type line causes a single update to occur. init.php contains nothing more than session_start and the database connection. When i comment-out the content-type line the page is blank with no errors or messages. I'm not sure why this is occurring. So say I have a script, it calls for a text file in the script. Instead of putting the name of the text file is there a way I can run the script then type the name of the file in the CLI? Hi everyone, Can anyone give me any pointers towards how to create a form like the listing add one on ebay? Basically the form fields are displayed depending on what type of product you have, I basically need something very similar where I have multiply categories but wish to have different inputs for each type? Many thanks hi there, i am fairly new to OOPs in php, i get an error when i declare the argument type (as object) in a function and pass the same type (object). class eBlast { public static function getEmail(object $result) { return $result->email; } } $r = mysql_fetch_object($query); eBlast::getEmail($r); echo gettype($r); // outputs: object error is : Code: [Select] Catchable fatal error: Argument 1 passed to eBlast::getEmail() must be an instance of object, instance of stdClass given, called in C:\wamp\www\integra\client\pl_eblast\admin\send_emails.php on line 145 and defined in C:\wamp\www\integra\client\pl_eblast\app\app.eBlast.php on line 8 if i remove the type declaration in the function it works, but just would like to know why it shows error when pass the same type, also isnt mysql_fetch_object is the instance of stdclass? thanks in advance! Long time lurker, first time poster here. I am having a problem with a multiple file uploader form I am trying to build. I am using the CodeIgniter framework, but I believe my problem is with the form itself. Here is the form: Code: [Select] <form action="http://localhost/show/submit" id="sendfiles" method="post" name="sendfiles" enctype="multipart/form-data"> <input type="hidden" name="doup" value="1" /> <input type="file" name="userfile1" value="" id="userfile1" size="20" /> <br /> <input type="file" name="userfile2" value="" id="userfile2" size="20" /> <br /> <input type="file" name="userfile3" value="" id="userfile3" size="20" /> <br /> <input type="submit" name="submit_btn" value="Upload" /> </form> The form is being passed to this function: if(empty($_POST['doup'])){ foreach($_REQUEST as $k => $v) print ">>> $k : $v <br />"; $data['form_open'] = form_open_multipart(uri_string(), array( 'id' => 'sendfiles', 'method' => 'post', 'name' => 'sendfiles' )); $data['form_flag'] = form_hidden('doup', '1'); $data['file1'] = form_input(array( 'id' => 'userfile1', 'name' => 'userfile1', 'size' => '20', 'type' => 'file', )); $data['file2'] = form_input(array( 'id' => 'userfile2', 'name' => 'userfile2', 'size' => '20', 'type' => 'file', )); $data['file3'] = form_input(array( 'id' => 'userfile3', 'name' => 'userfile3', 'size' => '20', 'type' => 'file', )); $data['form_submit'] = form_submit('submit_btn', 'Upload'); $data['form_close'] = form_close(); $this->load->view('show/submit', $data); } else { $config['allowed_types'] = 'mp3'; $config['max_size'] = '10240'; $config['upload_path'] = $this->config->item('file_upload_path'); $uploaded_files = array(); for($nona=1; $nona<4; $nona++){ if (strlen($_FILES['userfile'.$nona]['tmp_name']) <=0){ echo "tempname$nona failed"; continue; } //print "------ USERFILE $nona ------ <br />"; //print sizeof($_FILES['userfile'.$nona])."<br />"; //foreach ($_FILES['userfile'.$nona] as $k => $v){ // print "$k : $v <br />"; //} $this->upload->initialize($config); $upload = $this->upload->do_upload('userfile'.$nona); if (!$upload){ $form_errors = array('form_errors' => $this->upload->display_errors()); $this->load->view('show/submit', $form_errors); break; } else { $data = array('upload_data' => $this->upload->data()); $data = $data['upload_data']; $fp = $data['full_path']; $filename = strtolower(random_string('numeric', 16) . $data['file_ext']); $rel_path = 'show/submissons/uploaded/'; $path = $this->config->item('media_root_path') . $rel_path; exec('mkdir -p ' . $path , $a1, $r1); exec('mv ' . $fp . ' ' . $path . $filename, $a2, $r2); array_push($uploaded_files, $path . $filename); } } $this->session->set_flashdata('img_data',implode("||", $uploaded_files)); // redirect("show/submit_info"); } The problem is this: When I choose only one file to upload, it works. I can choose any of the 3 inputs and it works great. But as soon as I try to choose 2 or more files, the form fails to post. When I press submit, the page simply reloads and none of the form variables get posted. I have checked settings in php.ini and tried building and rebuilding this form. I'm hoping someone here can provide some insight into what I'm doing wrong? I have a form for a sign in page that I want the label for the form field to actually be displayed in the text box and clear when the box is selected to enter text. I've accomplished this using the code below and it works fine. The problem that I'm having is in IE the password field does not change to display dots or asterisk in place of each character. It works fine in Fire Fox but not in IE. Is there way to accomplish this using php or so that it is compatible with most browsers? Here's the code that I'm using: Code: [Select] <?php echo "<input type=\"text\" name=\"pword\" size=\"17\" value=\"Password...\" style=\"color: #999999\" onfocus=\"if (this.value == 'Password...') {this.value=''; this.style.color='#000000'; this.type='password';}\"> "; ?> Hi, I have a weather app, coded which creates weather based on a set zip code. I want to create a form which when the user fills out their local code and clicks the send button that will change the zip code variable. Currently it is set up like this $zip = '90210'; //change to your zipcode need help with getting started with this. Thanks! Hello everyone, I'm having a difficult time figuring out what my problem is here. I'm trying to submit a couple of strings (to the user they are messages to be sent to other users) and I am having trouble with the string being cut off at quotation marks. Here is the code that I'm using: Code: [Select] <?php if (isset($_POST['submit'])) { $staffmessage = $_POST['staffmessage']; $studentmessage = $_POST['studentmessage']; echo "$staffmessage<br /> <br />$studentmessage"; } ?> <!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" /> </head> <body> <?php $message1="This is a test message. It does not get cut off here when the \"quotation marks\" are added."; $message2="This is a test message. It DOES get cut off here when the \"quotation marks\" are added."; ?> <form name="form" method="post" action="test.php"> <textarea class="textarea" name="staffmessage" rows="12"> <?php echo $message1; ?> </textarea></p> <input name="studentmessage" type="hidden" value="<?php echo $message2; ?>" /> <input class="submit2" type="submit" name="submit" value="Send Message" /> </form> </body> </html> The result that I'm getting is that when $staffmessage is echoed, I get the full message. When $studentmessage is echoed, the message gets cut off at the first quotation mark. The only thing that is different when creating these two variables is that $staffmessage is submitted using a "textarea" field in the form, and $studentmessage is submitted using a "hidden" field in the form. Other than that, they are handled the exact same way. Can anyone please help me figure out how to remedy this so that $studentmessage is not cut off at the quotation mark? Thanks in advance for your help! Hi there, I was wondering if it was possible to change a forms action field with PHP. Basically, if there are several checkboxes for the user to select and a specific checkbox was selected, how would I redirect users to an alternative webpage on submit? I've been playing around with several methods, and one of them was: Code: [Select] <?php if(isset($_POST['Example']) && $_POST['Example'] == 'FormValueGoesHere') { echo ('./page1.php'); } else { echo ('./page2.php'); } ?> But the form action would only display page1.php even with nothing selected. Maybe I'm just being stupid because it's getting late, but I'd appreciate any assistance. Thanks Probably a stupid question . . .
The MIME type in my php.ini file is set to text/html:
default_mimetype = "text/html"But, because I use XHTML 1.0 Strict, the MIME type of my web pages is set to text/xml: <meta http-equiv="content-type" content="text/xml; charset=utf-8" />I should therefore change the php.ini MIME type to text/xml, right? I have a Form and need to loop through 10 fields on it. Which Looping Structure would be best and why? In PHP, I believe my choices are... - For Each - Do While - While Thanks, Debbie Is it not possible to get the mime type for a file uploaded using php? Am I going to be forced to use Pear? Php can read the mime type from an image, so why not from any file?? Hello, Does anyone know how may i detect the Connection type by user IP? Broadband etc. Hey In my spare time, I am working on my PHP framework. Now, to help with development and quickly discover where I miss a type cast, I have adopted to check all parameters that are passed to a method using a function. For instance: public function __construct(&$target = null, $depth = 1){ $this->validateArguments( array(1 => 'int'), array(1 => $depth) ); And the code that triggers the exception: public function testPhpFreakType(){ $obj = 1; $p = new Xcms_DataStructures_Pointer($obj, "1"); } Code: [Select] 0: |--------------------------------------------------| 1: |--Exception: 4cfe2e86ca5970.22624423 - Full Trace | 2: | Tue, 07 Dec 2010 13:54:30 +0100 3: |-Class: 4: | Xcms_Exceptions_InvalidArgument 5: |-Message: 6: | Argument #1 of Xcms_DataStructures_Pointer:__construct() is no _null:int 7: | Stack offset: 3 8: | 9: |-Trace 10: | #0 D:\www\xcms_rev\core\exceptions\invalid.argument.helper.class.php(133): Xcms_Exceptions_InvalidArgumentHelper::factory(1, '_null:int', NULL, 2) 11: | #1 D:\www\xcms_rev\core\basic.class.php(80): Xcms_Exceptions_InvalidArgumentHelper::validateArguments(Array, Array, Array, 1) 12: | #2 D:\www\xcms_rev\core\data.structures\pointer.class.php(49): Xcms_Basic->validateArguments(Array, Array) 13: | #3 D:\www\xcms_rev\core\data.structures\pointer.test.php(73): Xcms_DataStructures_Pointer->__construct(1, '1') 14: | #4 [internal function]: Xcms_DataStructures_PointerTest->testPhpFreakType() 15: | #5 C:\xampp\php\PEAR\PHPUnit\Framework\TestCase.php(737): ReflectionMethod->invokeArgs(Object(Xcms_DataStructures_PointerTest), Array) 16: | #6 C:\xampp\php\PEAR\PHPUnit\Framework\TestCase.php(627): PHPUnit_Framework_TestCase->runTest() 17: | #7 C:\xampp\php\PEAR\PHPUnit\Framework\TestResult.php(629): PHPUnit_Framework_TestCase->runBare() 18: | #8 C:\xampp\php\PEAR\PHPUnit\Framework\TestCase.php(575): PHPUnit_Framework_TestResult->run(Object(Xcms_DataStructures_PointerTest)) 19: | #9 C:\xampp\php\PEAR\PHPUnit\Framework\TestSuite.php(766): PHPUnit_Framework_TestCase->run(Object(PHPUnit_Framework_TestResult)) 20: | #10 C:\xampp\php\PEAR\PHPUnit\Framework\TestSuite.php(742): PHPUnit_Framework_TestSuite->runTest(Object(Xcms_DataStructures_PointerTest), Object(PHPUnit_Framework_TestResult)) 21: | #11 D:\www\xcms_rev\core\testing\manager.class.php(83): PHPUnit_Framework_TestSuite->run() 22: | #12 D:\www\xcms_rev\core\testing\manager.class.php(56): Xcms_Testing_Manager->testClass(Object(ReflectionClass)) 23: | #13 D:\www\xcms_rev\cache\pkg\scripting\script_1.php(3): Xcms_Testing_Manager->run(Object(Xcms_Url_DefaultRequest)) 24: | #14 D:\www\xcms_rev\core\util.lib.php(340): include('D:\www\xcms_rev...') 25: | #15 D:\www\xcms_rev\core\packages\scripting\controllers\scripting.controller.php(66): Xcms_Util::sandboxedInclude('cache/pkg/scrip...', Array) 26: | #16 D:\www\xcms_rev\core\mvc\controllers\default.controller.php(210): Xcms_Packages_Scripting_Controllers_ScriptingController->execute(Object(Xcms_Packages_Scripting_Models_ScriptModel), Object(Xcms_Templating_Context)) 27: | #17 D:\www\xcms_rev\core\mvc\controllers\default.controller.php(170): Xcms_Mvc_Controllers_DefaultController->runScript(1, 0, Object(Xcms_Templating_Context)) 28: | #18 D:\www\xcms_rev\core\mvc\controllers\default.controller.php(132): Xcms_Mvc_Controllers_DefaultController->runScripts(0, 0, Array, Array, 1, 0) 29: | #19 D:\www\xcms_rev\index.php(15): Xcms_Mvc_Controllers_DefaultController->run() 30: | #20 {main} 31: |--------------------------------------------------| I think this speeds up my development quite a bit, because I can catch errors very early in the development process. I can give multipe possibilities of what is allowed for each parameter, not just a single possibility. Also, it is possible to register custom type/validity-checks on both global and local scope. One thing I do worry about, however, is the the performance. Of course, I could just make the funciton do nothing in production code, if it takes too much time, or I could write a script to remove all calls to that function. When I started learning python a while back, the concept to just code to interfaces instead of types seemed very intuitive and made my code much more flexible. Of course that is what I do with PHP as well, but I it's not entirely the same. So now, coming back at my PHP code and having introduced features of static languages such as type checking, I worry about whether that is the right approach. What are your thoughts on the matter? Is there any possible way to determine a drive type (e.g., hard disk, dvd drive, usb drive, etc.) and partition type (e.g., NTFS, CDFS, ext3, etc.) in php without the use of COM and importing OS resources? I ask, because I am developing a custom system explorer for a web application. I already know how to detect drives, drive size/usage and associated drive letters, but am curious if any built-in functions of php can do this. Any help is appreciated. Is there a way to find out what the array type is? Example: Code: [Select] $array1 = array('red', 'pizza', '14'); $array2 = array('color' => 'red', 'food' => 'pizza', 'age' => '14'); if(is_recursive($array1)){ return TRUE; } else if(is_multidimensional($array2){ return TRUE; } else { return FALSE; } This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=308253.0 $_GET['id'] = (empty($_GET['id'])) ? 0 : $_GET['id']; I'm going over someones code, the site is super flawed, Ive got to much going on at once and I can't wrap my head around that. Is it if the string is empty or 0 then use the get variable or is it something else? |