Jump to content

critical-state

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Everything posted by critical-state

  1. Can anyone shed some light why I am unable to get this to work? This is a test of a script that I am working on. I want to test and use the condition "if(isset($_POST['submit']" so that I am able to exit(); the page and call up a new one after my form has been submitted. It works fine is I use a submit button. But I want to use an image button. Can any one help?? Hope you can understand what I am on about <form method="post" action="" name="test"> <input type ="text" name="test" maxlength="20" value="Enter data Here"> <input type="image" name="submit" src="/images/profilebutton.png" value ="Update Profile"> </form> <?php if(isset($_POST["submit"])){ echo "Submit has been pressed";//can't get this to work when input type is an image??? }else{ echo" waiting for responce"; } ?>
  2. Cheers I have now sussed it. I should have used output buffering at the top of my page. thanks for the advice though!
  3. Hi, I am having issues with some code I have written. I have commented the problem section below. the warning message I am receiving is:Warning: Cannot modify header information - headers already sent by (output started at C:\www\Projects\test2.php:21) in C:\www\Projects\test2.php on line 33. Any ideas or a way round would be great! Andy <select name="day"> <?php error_reporting(E_ALL); $day=0; $year=0; $_POST['day']=0; $_POST['year']=0; for($day=01;$day<=31; $day++) { echo"<option value='".$day."'"; if($day==$_POST['day'])echo "selected"; echo ">" .$day. "</option>\n"; } ?> </select> <select name="year"> <?php for($year=date("Y");$year>=1900; $year--)//If I set the year to above 1922 I do not get the error message ??? { echo"<option value='".$year."'"; if($day==$_POST['year'])echo "selected"; echo ">" .$year. "</option>\n"; } ?> <input type="submit" value="go"> <?php $url= "http://localhost/projects/confirm_signup.php"; header ("location: $url"); exit(); ?>
  4. Ok I will try and explain better. Had I not used the array_splice and run the script and chose for example "gin". I would be getting): gin as my choice in the display field. If I then go to re-select I would get: gin gin guiness larger beer vodka I dont want this duplication so I use array_splice I run the script choose for example "gin" my script is working correctly and displaying: gin as my choice in the display field. If I then go to re-select I get: gin guiness larger beer vodka. This is all working correct. All drinks are working as expected ie no duplication when re-selecting except guiness. if I run the script and choose guiness, I get: guiness for my choice and then if I re-select I get: guiness guiness As I said this was oridinally all working correctly until I temporary changed my array_splice and $drinks array. Its seems that some how I have effected the arrays position in some form and it needs re-setting some how. If I change this: if($_POST['drink']=="guiness"){array_splice($drinks,-4);} to this if($_POST['drink']=="guiness"){array_splice($drinks,-2);} it should then be showing only the last two drinks in the array. However it shows on my machine the following: guiness (selected) guiness guiness larger beer It's as though it is working in a reverse order ????????? I am baffled ??? Please help Andy
  5. Hi, hoping somone can shed some light on a problem I am having when using an array_splice to remove elements from an array. I am new to php so maybe my approach or method is wrong? I am trying to ensure that when a user selects from a <option> list of drinks </option> the drink selected is displayed within the form but not duplicated. oridinally it worked as expected. However I temporaly changed part of my array and when I put it back it no longer works as it should on my system. I have even tried creating new arrays but am still having the same problem with the first element of any array that I create. Am I doing somthing wrong is there a way to reset the array to work as it oridinally did? <?php error_reporting(E_ALL); //define varables: $d_color=0; $drinks=array("guiness","larger","beer","vodka","gin"); if(!isset($_POST['drink'])){$_POST['drink']="Choose One" ; $d_color="black";} if($_POST['drink']=="guiness"){array_splice($drinks,-4);}/* When I run the code for some reason it shows up as guiness, guiness with no other drinks listed? it should show all drinks except guiness. although guiness will show as it is retained and displayed by the echo $_POST['drinks'] array*/ if($_POST['drink']=="larger"){array_splice($drinks,1,-3);}// this works as expected no duplication of larger if($_POST['drink']=="beer"){array_splice($drinks,2,-2);}//this works as expected if($_POST['drink']=="vodka"){array_splice($drinks,3,-1);}// this works as expected if($_POST['drink']=="gin"){array_splice($drinks,4);}//this works as expected ?> <form method="post" action=""> <?php echo"<font color=\"$d_color\">Choose Drink</font>";?><select style="display:block;" name="drink"> <option><?php echo $_POST['drink'];?></option> <?php foreach($drinks as $drink){ echo "<option>" .$drink ."</option>"; } ?> </select> <input type ="submit" value ="go"> </form>
  6. Cheers craygo I have switched my error checking on and yes there are all sorts of issues with my original code. Thanks for the tip and the code Andy
  7. Hi I did see that there is a money format function listed here: http://www.php.net/manual/en/function.money-format.php although I don't think its fuctional on windows for some reason. very basic but have you tried this: <?php $value = 1234.56; $euro= "€"; $output= $euro.$value; echo $output; ?>
  8. Hi I am hoping that some one can give me some understanding and a soloution to a problem I am having with my $email string loosing it data after I submit the second part of a form. This is not the actual script but a test to show what I mean about the string loosing it data. I have only been studying php and HTML for a couple of weeks so if my code looks basic, please excuse. Any feedback or comments welcome Cheers Crit. <html> <body> <form method="post" name="test" action=""> Enter your new email address here: <input type ="text" size="30" name ="email"> <input type="submit" value="GO!"> </form> <?php $email=$_POST['email']; $change['email']=trim((!empty($_POST['email'])) ? $_POST['email']: $_GET['email']); if(strlen($change['email'])>3){ ?> <form method="post" action="" name="yes/no"> Yes<input type="radio" name="yes_no" value="yes"> No<input type="radio" name="yes_no" value="no"> Confirm changes: <input type="submit" value ="Confirm"> </form> <?php } if($_POST['yes_no']=="yes"){ echo" Your email address is: $email";// $email should be displaying the new email address. but after yes_no submit, no data is shown why? ??? echo " Why is this bloody not displaying the set varable!!! $email"; :-\ } echo $email; ?> </body> </html>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.