Forum     

Go Back   Digit Technology Discussion Forum > Portables, Peripherals and Electronics > QnA (read only)
Register FAQ Calendar Mark Forums Read

QnA (read only) Mods please help transfer the contents of this forum to proper sections. :)


 
 
LinkBack Thread Tools Search this Thread Display Modes
Old 24-09-2007, 05:09 PM   #1 (permalink)
Drool!...Vista
 
*GandaBerunda*'s Avatar
 
Join Date: Mar 2007
Posts: 91
Default help in php coding


i am having a textbox and a button on my website..i want whatever the user enters in da box to be saved to a textfile on the server...how can i do so?
after writing it should automatically redirect to another address....can someone please guide me?
i think i can do this by opening a php file using "OnClick" and then redirecting thorugh the php file after the data has been written.....can someone please give me the complete code?
this is the code tat i get when i click on the button in ms expression web
<input name="Button1" type="button" value="Sign in">
and the name of the textbox is text1

pleaze give me the entire code if i want to write the text to a file in the dir
http://xxxx.xxxx.com/text.txt
__________________
Visit my blog http:\\geekgarbage.blogspot.com, but don't click on the ads :)
*GandaBerunda* is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 24-09-2007, 05:27 PM   #2 (permalink)
Host4Cheap.org
 
Sukhdeep Singh's Avatar
 
Join Date: May 2005
Location: Digit Forum
Posts: 2,102
Default Re: help in php coding

No need to open nother account. You could have posted in your old topic regarding problems you faced
some one help me...need php help...
__________________
★ Want to start your Website, No worries - here is how ★
http://www.thinkdigit.com/forum/showthread.php?t=66717

★ Host4Cheap - cPanel Webhosting & Reseller Plans ★
http://www.host4cheap.org/
Sukhdeep Singh is offline  
Old 24-09-2007, 05:36 PM   #3 (permalink)
"The Cake is a Lie!!"
 
[xubz]'s Avatar
 
Join Date: Oct 2006
Posts: 471
Default Re: help in php coding

Heh

Coded this in 15mins, So Post back if you get any Errors

3 Files
1) test.html
2) test.php
3) text.txt

test.html
PHP Code:
<form action="test.php" method="post">
    <
input type="text" name="tbName" /><br />
    <
input type="submit" name="btnSubmit" value="Submit" />
</
form
test.php
PHP Code:
<?php
//Check if the Form is Posted
if (isset($_POST))
{
    
$success false;

    
//Validate the Fields
    
if ((isset($_POST['tbName']) && $_POST['tbName'] != '') &&
        (isset(
$_POST['btnSubmit']) && $_POST['btnSubmit'] == 'Submit'))
    {
        
$fcontents file_get_contents('./text.txt'); //Get the Contents of the File
        
if (is_writable('./text.txt')) //Check if the File is Writable
        
{
            
//Open the File and fput the contents. (Don't forget to add CR+LF)
            
$fp = @fopen('./text.txt''w');
            @
fputs($fp$fcontents);
            @
fputs($fp$_POST['tbName']);
            @
fputs($fp"\r\n");
            @
fclose($fp);

            
$success true//Set Success Boolean to true
        
}
        else
        {
            echo 
'File not Writable';
        }
        
        
//If Success is true, then Redirect to a Different Page
        
if ($success)
        {
            
$redir_page './test.html'//Can be set to http://gmail.com/, etc.
            
header('Location: ' $redir_page);
        }
    }
    else
    {
        echo 
'Please Fill all the Fields';
    }
}
?>
text.txt
Code:
Data
-----
(Don't forget to add a blank like at EOF)


The script maybe a little inefficient, but it can be modified

(Yeh! I had some time to waste )
__________________
[xubz] ● http://xubz.com/
[steam_id] ● http://steamcommunity.com/id/xubz
[xubz] is offline  
 

Bookmarks

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Building website without coding madmoody QnA (read only) 10 18-03-2007 01:40 PM
DVD region coding digit_rajesh QnA (read only) 4 14-02-2007 07:12 PM
Coding Language Used nitish_mythology Programming 1 25-10-2005 09:59 AM

 
Latest Threads
- by ico
- by Charan
- by Piyush
- by icebags
- by clinton

Advertisement




All times are GMT +5.5. The time now is 12:25 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2