Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Simple _POST question

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Simple _POST question

Postby gary84 » Sat Jul 06, 2013 8:39 am

Simple question. How do I change this, such that pressing the upper save button saves both the upper and the lower text box at the same time, even if I've edited text in only one of the boxes. I just want to combine the two SAVE buttons into one. Thanks.

Code: Select all
<?php
$fn01 = "clips1.txt";
$fn02 = "clips2.txt";

if (isset($_POST['content01']))
{
 $content01 = stripslashes($_POST['content01']);
 $fp = fopen($fn01,"w") or die ("error");
 fputs($fp,$content01);
 fclose($fp) or die ("error");
}

if (isset($_POST['content02']))
{
 $content02 = stripslashes($_POST['content02']);
 $fp = fopen($fn02,"w") or die ("error");
 fputs($fp,$content02);
 fclose($fp) or die ("error");
}
?>

<form action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post">
 <textarea rows="20" cols="100" name="content01"><?php readfile($fn01); ?></textarea> </br>
<input type="submit" value="save">
<input type="reset" value="reset"></br>
</form>


<form action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post">
 <textarea rows="20" cols="100" name="content02"><?php readfile($fn02); ?></textarea> </br>
<input type="submit" value="save">
<input type="reset" value="reset"></br>
</form>
gary84
New php-forum User
New php-forum User
 
Posts: 2
Joined: Sat Jul 06, 2013 8:35 am

Re: Simple _POST question

Postby johnj » Tue Jul 09, 2013 12:02 am

Just remove these 2 lines
Code: Select all
</form>


<form action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post">
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: Simple _POST question

Postby gary84 » Sat Jul 13, 2013 3:19 pm

Yep that worked. I thought the posting was being done by the top IF statements, not the bottom part. Thanks.
gary84
New php-forum User
New php-forum User
 
Posts: 2
Joined: Sat Jul 06, 2013 8:35 am


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot], Google Feedfetcher and 4 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.