|
-
March 23rd, 2007, 05:09 AM
#1
Please help me , Post Data & Store Data
Hi guys
want to make a form with 2 actions, means by 1 click 2 actions performs and I do not want to use PHP_SELF, because the first action address is the main target and the second one is to store data
its my code but it doesn't store data in "test.txt" just posts to "http://mysite.com/11.php"
PHP Code:
<?php
$st = "
<form action='http://mysite.com/11.php' method='post'>
Name: <input type='text' name='name' />
Age: <input type='text' name='age' />
<input type='submit' />
</form>
";
echo $st;
$name = stripslashes($name);
$age = stripslashes($age);
$logs = fopen('test.txt', 'a', 1);
$mytext="
$name , $age ";
fwrite($logs, $mytext);
fclose($logs);
?>
Thanks
-
March 23rd, 2007, 07:36 AM
#2
Re: Please help me , Post Data & Store Data
Well, I don't understand the 1 in your fopen(), nor do I understand why your variable to be written is two lines. Just use \n to do line returns.
Use the following to see where your code is failing.
PHP Code:
$name = stripslashes($name);
$age = stripslashes($age);
if($logs = fopen('test.txt', 'a')){
$mytext="\n$name , $age";
if(!fwrite($logs, $mytext)){echo 'Could not write to file.';}
fclose($logs);
}
else{echo 'File could not be opened!';}
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
March 23rd, 2007, 08:47 AM
#3
Re: Please help me , Post Data & Store Data
problem is not on writing of file
it will writes if you change the post action to 11.php , but it will just post data localy and saves data to file and doesn't send the data to the other site , how ever i want to the script does both
-
March 23rd, 2007, 08:53 AM
#4
Re: Please help me , Post Data & Store Data
Oh, well then why don't you just put the fwrite code in the 11.php? That is your server-side script file.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
March 23rd, 2007, 09:40 AM
#5
Re: Please help me , Post Data & Store Data
because i don't have access to 2nd host
-
March 23rd, 2007, 10:04 AM
#6
Re: Please help me , Post Data & Store Data
Then you have to use JavaScript to submit the form once with a different window being the target, and then again with the regular window.
Code:
function submitform(){
document.formname.action = "http://mysite.com/11.php";
document.formname.target = "_blank";
document.formname.submit;
document.formname.action = "";
document.formname.target = "_self";
document.formname.submit;
}
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
March 23rd, 2007, 06:11 PM
#7
Re: Please help me , Post Data & Store Data
thanks , it worked
-
March 23rd, 2007, 06:12 PM
#8
Re: Please help me , Post Data & Store Data
Glad to hear it. You're welcome.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|