Lost Password?


Go Back   CodeCall Programming Forum > Web Development Forum > PHP Forum

PHP Forum Use this forum to discuss all aspects of PHP Development. PHP is a server-side, cross-platform, HTML embedded scripting language that lets you create dynamic web pages.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-23-2007, 06:11 AM
minusp minusp is offline
Newbie
 
Join Date: Feb 2007
Posts: 6
Rep Power: 0
minusp is on a distinguished road
Post 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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 03-23-2007, 07:21 AM
Lop's Avatar   
Lop Lop is offline
Speaks fluent binary
 
Join Date: May 2006
Posts: 1,149
Rep Power: 18
Lop will become famous soon enoughLop will become famous soon enough
Default

Everything looks good here, does test.txt have world permission (Writable permission, 777)?

You might want to put a condition to handle if the file is not open, then you will be able to determine if the file is open.

PHP Code:
if (($fp fopen($filename"r+") === FALSE) {
  
// handle error
  
exit;

__________________
Lop
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-23-2007, 07:51 AM
minusp minusp is offline
Newbie
 
Join Date: Feb 2007
Posts: 6
Rep Power: 0
minusp is on a distinguished road
Default

problem is not premission
it can write if you change the action to 11.php, but if you do it , it just writes in the file , and doesn't post data to mysite.com/11.php
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 03-23-2007, 08:11 AM
Jaan's Avatar   
Jaan Jaan is offline
Mod
 
Join Date: Dec 2006
Location: Estonia
Age: 17
Posts: 930
Last Blog:
AdStar Ad Control Pa...
Rep Power: 16
Jaan is a jewel in the roughJaan is a jewel in the roughJaan is a jewel in the roughJaan is a jewel in the rough
Send a message via MSN to Jaan
Default

but try this..

PHP Code:
<?php

function form(){

<
form action='myfile.php?act=write' method='post'>
Name: <input type='text' name='name' />
Age: <input type='text' name='age' />
<
input type='submit' />
</
form>
}

function 
write(){
$name $_REQUEST['name'];
$age $_REQUEST['age'];
$name stripslashes($name);
$age stripslashes($age);
$logs fopen('test.txt''a'1);
$mytext="
$name , $age "
;

fwrite($logs$mytext);
fclose($logs);
}

switch(
$act){

default;
form();
break;

case 
"write";
write();
break;

}

?>
i'm pretty sure that this does the job..
just change this:

<form action='myfile.php?act=write' method='post'>
__________________


Cheap & Professional Web Design | Need help? Send a PM
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 03-23-2007, 08:34 AM
minusp minusp is offline
Newbie
 
Join Date: Feb 2007
Posts: 6
Rep Power: 0
minusp is on a distinguished road
Default

thanks but its php_self and i want to post the data to another site 'http://mysite.com/11.php'
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #6 (permalink)  
Old 03-23-2007, 11:27 AM
Jaan's Avatar   
Jaan Jaan is offline
Mod
 
Join Date: Dec 2006
Location: Estonia
Age: 17
Posts: 930
Last Blog:
AdStar Ad Control Pa...
Rep Power: 16
Jaan is a jewel in the roughJaan is a jewel in the roughJaan is a jewel in the roughJaan is a jewel in the rough
Send a message via MSN to Jaan
Default

well hmm.. ookay:

form.php
PHP Code:
<?php
echo "<form action='http://mysite.com/11.php' method='post'>
Name: <input type='text' name='name' /><br>
Age: <input type='text' name='age' /><br>
<input type='submit' />
</form>"
;
?>
Now you must insert this part into your 11.php file:
PHP Code:
<?php
$name 
$_POST['name'];
$age $_POST['age'];
$name stripslashes($name);
$age stripslashes($age);
$logs fopen('test.txt''w');
$mytext="
$name , $age "
;

$write fwrite($logs$mytext);
if(!
$write){
die(
"Can not write info into file!");
}
fclose($logs);
?>
and it works
__________________


Cheap & Professional Web Design | Need help? Send a PM
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 03-23-2007, 07:10 PM
minusp minusp is offline
Newbie
 
Join Date: Feb 2007
Posts: 6
Rep Power: 0
minusp is on a distinguished road
Default

thanks , worked
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 03-23-2007, 08:00 PM
Jaan's Avatar   
Jaan Jaan is offline
Mod
 
Join Date: Dec 2006
Location: Estonia
Age: 17
Posts: 930
Last Blog:
AdStar Ad Control Pa...
Rep Power: 16
Jaan is a jewel in the roughJaan is a jewel in the roughJaan is a jewel in the roughJaan is a jewel in the rough
Send a message via MSN to Jaan
Default

you're welcome
__________________


Cheap & Professional Web Design | Need help? Send a PM
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Word Assoc [Post 1000] Lop The Lounge 1007 04-26-2008 12:43 PM
Java:Tutorial - Data Types John Java Tutorials 6 07-02-2007 10:16 PM
Fetching Data from a Form Generated Website pclark2 General Programming 5 05-11-2007 07:24 AM
14 Ways to SEO Wordpress xtraze Search Engine Optimization 4 04-23-2007 06:03 PM


All times are GMT -5. The time now is 04:02 PM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 98%

Ads