Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
[Need Help] Saving input url into a text file
Old 10-01-2008, 02:05 PM [Need Help] Saving input url into a text file
Experienced Talker

Posts: 38
Trades: 0
I have a small idea I and would like to know if someone could help with it

I have proxy sites and would like to be able to save the inputted url into a text file so I am able to later know the most popular sites and make sure the proxy is up to par for those sites.
PHP Code:

<form class="url_form" method="post" action="{SCRIPT_URL}">
<
div id="surfcontainer">
                    <
input type="text" id="surfbox" name="q" value="{DEFAULT_URL}" />
                    <
input type="image" value="" src="{THEME_DIR}/imgs/surf_button.gif" style="float: left; border: 0px;" />

</
form>
</
div
This is the current form field that I would like to save the inputted url and in the text file all the urls on individual lines. Would be great if the saved url were live links so I could just click on them.


I tried to use this but it does not save all queries on some and I dont know what to chmod the txt file to

PHP Code:
<!-- save query //-->
<?php

if($_POST['q']){
$file_name "something.txt";

$file_open fopen("something.txt","a+");
fwrite($file_open$_POST['q']);
fclose($file_open);
}
?>
<!-- end save query //-->

<form class="url_form" method="post" action="/index.php">
<div id="surfcontainer">
                    <input type="text" id="surfbox" name="q" value="{DEFAULT_URL}" />
                    <input type="image" value="" src="{THEME_DIR}/imgs/surf_button.gif" style="float: left; border: 0px;" />

</form>
</div>
This doesnt work right and gave an error saying
Quote:
Undefined index: q
So could someone please help me to get a working version of this please.
__________________

Please login or register to view this content. Registration is FREE
::
Please login or register to view this content. Registration is FREE
::
Please login or register to view this content. Registration is FREE
ChillyWilly is offline
Reply With Quote
View Public Profile Visit ChillyWilly's homepage!
 
 
Register now for full access!
Old 10-01-2008, 02:40 PM Re: [Need Help] Saving input url into a text file
Sleeping Troll's Avatar
Ultra Talker

Posts: 351
Name: Butch Begy
Trades: 0
<?php

if ('q'=$_POST['name'])
$file_name = "something.txt";
fopen($file_name,"a+");
fwrite($filename, $_POST['name']);
fclose($file_open);
}
?>

Last edited by Sleeping Troll; 10-01-2008 at 02:46 PM..
Sleeping Troll is offline
Reply With Quote
View Public Profile
 
Old 10-01-2008, 02:43 PM Re: [Need Help] Saving input url into a text file
Experienced Talker

Posts: 41
Name: Jabis Sevon
Location: Tampere, Finland
Trades: 0
Hi there,

The undefined index is your $_POST['q'] which needs to be tested before using it.
Try something like this:

PHP Code:
<?php
if(isset($_POST['q'])){
$postdata $_POST['q'];
$fp "something.txt";
if(!
is_file($fp)) {
echo 
$fp." didn't exist, trying to touch and chmod<br/>"
touch($fp);
@
chmod($fp0666);
}
if(!
is_writable($fp)) {
echo 
$fp." is not writable<br/>";
$error true;
} else {
echo 
"..."$fp." is OK <br/>";
}
if(!
$error) {
$data file_get_contents($fp);
// echo $data; //uncomment this ln to see the data prior to writing
$data .= "\r\n".$postdata;
// echo $data; // uncomment this ln to see the data after writing
 
file_put_contents($fp$data);
echo 
"... And we're done!";
}
}
?>

Last edited by jabis; 10-01-2008 at 02:44 PM..
jabis is offline
Reply With Quote
View Public Profile Visit jabis's homepage!
 
Old 10-01-2008, 03:04 PM Re: [Need Help] Saving input url into a text file
Experienced Talker

Posts: 38
Trades: 0
1st solution didnt resolve the error the 2nd one gives no error but no results.

Can see it running live on the proxy you can see the text file of the queries here


So I am guess the "q" might be the issue So I just want to save the results that are inputted into the url form not sure what its doing.
__________________

Please login or register to view this content. Registration is FREE
::
Please login or register to view this content. Registration is FREE
::
Please login or register to view this content. Registration is FREE
ChillyWilly is offline
Reply With Quote
View Public Profile Visit ChillyWilly's homepage!
 
Old 10-01-2008, 03:19 PM Re: [Need Help] Saving input url into a text file
Experienced Talker

Posts: 41
Name: Jabis Sevon
Location: Tampere, Finland
Trades: 0
ChillyWilly, be sure the chmod is world-writable and the writing script has execution rights

And as far as I can see, it's doing it's job

http://profile.myspace.com/index.cfm...endid=24475365

came to something.txt after I clicked myspace proxy.

or then maybe not...

Last edited by jabis; 10-01-2008 at 03:24 PM.. Reason: is unsure
jabis is offline
Reply With Quote
View Public Profile Visit jabis's homepage!
 
Old 10-01-2008, 03:23 PM Re: [Need Help] Saving input url into a text file
Experienced Talker

Posts: 38
Trades: 0
but try going to espn.com msn.com or any other tld it doesnt save it. The txt file is 666
__________________

Please login or register to view this content. Registration is FREE
::
Please login or register to view this content. Registration is FREE
::
Please login or register to view this content. Registration is FREE

Last edited by ChillyWilly; 10-01-2008 at 03:39 PM..
ChillyWilly is offline
Reply With Quote
View Public Profile Visit ChillyWilly's homepage!
 
Old 10-01-2008, 03:45 PM Re: [Need Help] Saving input url into a text file
Experienced Talker

Posts: 41
Name: Jabis Sevon
Location: Tampere, Finland
Trades: 0
The scripts definately doing something right, but there seems to be some probs with it, wouldn't know without the whole source though
Keep at it - you're going to the right direction at least, 'cause It's logging some urls :>
jabis is offline
Reply With Quote
View Public Profile Visit jabis's homepage!
 
Old 10-01-2008, 03:47 PM Re: [Need Help] Saving input url into a text file
Experienced Talker

Posts: 38
Trades: 0
ok, thanks for trying
__________________

Please login or register to view this content. Registration is FREE
::
Please login or register to view this content. Registration is FREE
::
Please login or register to view this content. Registration is FREE
ChillyWilly is offline
Reply With Quote
View Public Profile Visit ChillyWilly's homepage!
 
Reply     « Reply to [Need Help] Saving input url into a text file
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.27484 seconds with 12 queries