/    Sign up×
Community /Pin to ProfileBookmark

right then,
I’ve quickly just put a script together capturing email addresses. User inputs email address and presses submit, sent to php and then written to text file.

File names are:-
input.htm, submit.php, subscribers.txt.

But i’m getting an error message. I have set all these 3 files CHMOD to 777.

Here’s my form – [url]http://www.orbitalsys.pwp.blueyonder.co.uk/TESTING/input.htm[/url]

or screenshot of error [url]http://www.orbitalsys.pwp.blueyonder.co.uk/TESTING/screenshot_error.jpg[/url]

any ideas what this means?

Regards,
Russell

to post a comment
PHP

19 Comments(s)

Copy linkTweet thisAlerts:
@LiL_aaronJan 30.2006 — The error message your getting is because the form uses POST to send the data:

<form action="POST"...

You can use "GET" instead, but its not recommended. Try asking your webhost to enable the "POST" method or ask them why they do not allow it.
Copy linkTweet thisAlerts:
@LiL_aaronJan 30.2006 — another thing u could try is this... make input a php file too... then both files are the same ie .php

this may or may not work... but worth a try ?
Copy linkTweet thisAlerts:
@russellkainauthorJan 30.2006 — How would I change my files to use the GET command?

[B]input.htm[/B]

<html>

<head>

<title>Subcribe</title>

</head>

<body>

<form name="subscribe" action="submit.php" method="POST">

Enter your email address : <input type="text" name="emailadd" /><br

/>

<input type="submit" name="submit" value="Subscribe" />

</form>

</body>

</html>

[B]submit.php[/B]

<?php

$emailAddress = $_POST['emailadd'];

if(!$emailAddress)

{

echo "Please enter your email address.";

exit;

}

else

{

$filename = "subscribers.txt";

$content = "$emailAddressn";

$fp = fopen($filename, "a");

$fw = fwrite( $fp, $content );

fclose( $fp );

if(!$fw) echo "Couldn't write the entry.";

else echo "Successfully wrote to the file.";

}

?>

any ideas?

regards,

Russell
Copy linkTweet thisAlerts:
@NogDogJan 30.2006 — [b]method="get"[/b] in the <form> tag, then substitute $_GET where you have $_POST in the script.
Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYJan 30.2006 — oh and russell, don't cross-post or double post
Copy linkTweet thisAlerts:
@russellkainauthorJan 30.2006 — haha ? I don't have an igloo what you just said
Copy linkTweet thisAlerts:
@russellkainauthorJan 30.2006 — right! changed the POST's to GET's in both files and now when i run input.htm and try to submit the computer tries to download the php file?

eh! ?

http://www.orbitalsys.pwp.blueyonder.co.uk/TESTING/download_error.jpg

thanks

Russ
Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYJan 30.2006 — hmm, your host doesn't seem to support php

try the following:

create a new file, call it 'info.php'

and inside place:
[code=php]
<?php
phpinfo();
?>
[/code]


then run the file, if te page isn't blank, or if the browser doesn't prompt you a download box, then post the link.

If however it doesn't work, then your host probably doesn't support PHP.

I'd change to a host that has PHP support and POST enabled
Copy linkTweet thisAlerts:
@LiL_aaronJan 30.2006 — hi,

Just tested your script on my server... works fine, with post...

So this means, your server (blueyonder) does not support php... normally free hosts, or free host from your isp does not allow php... so you will have to get another host... i recommand www.midphase.com

Anyways you can see your script working here:

[URL=http://www.xpixal.com/test/test/input.php]input.php[/URL]

and the txt file:

[URL=http://www.xpixal.com/test/test/userlist.txt]userlist.txt[/URL]


(*TO ADMIN: I am not sure if advertising is allow on these forums... i am sorry i have gone against any rules.*)
Copy linkTweet thisAlerts:
@bathurst_guyJan 30.2006 — (*TO ADMIN: I am not sure if advertising is allow on these forums... i am sorry i have gone against any rules.*)[/QUOTE]Yes, advertising is against rules (glad you read them when you signed up!). Though, I read this as a suggestion (which in my mind, is slightly different) although, I don't have authority in the PHP forum, and so the Mod of this forum may or maynot remove this.
Copy linkTweet thisAlerts:
@russellkainauthorJan 30.2006 — Yeay! got it working

Here's what I want to do now.

here's my code

[COLOR=Magenta]html>

<head>

<title>Add New User</title>

</head>

<body>

<form name="Add New User" action="submit.php" method="GET">

Enter a username: <input type="text" name="useradd" /><br

/>

<input type="submit" name="submit" value="Add user" />

</form>

</body>

</html>[/COLOR]


so this code is taking the details from the 'enter a username' field and submitting to the php file, and the php in turn submits to the text file. However I need to have two boxes for data and i need them both to be submitted to the text file.

Anyone fancy writing that for me?

regards,

Russell
Copy linkTweet thisAlerts:
@LiL_aaronJan 30.2006 — Try this mate

[code=php]<html>
<head>
<title>Subcribe</title>
</head>
<body>
<form name="subscribe" action="submit.php" method="POST">
Enter your email address : <input type="text" name="emailadd" /><br
/>
Enter your password : <input type="text" type=password name="password" /><br
/>
<input type="submit" name="submit" value="Subscribe" />
</form>
</body>
</html>
[/code]


[code=php]<?php
$emailAddress = $_POST['emailadd'];
$passWord = $_POST['password'];

if(!$emailAddress)
{
echo "Please enter your email address.";
exit;
}
else
{
$filename = "userlist.txt";
$content = "$emailAddressn";
$fp = fopen($filename, "a");
$fw = fwrite( $fp, $content );
fclose( $fp );
if(!$fw) echo "Couldn't write the email entry.";
else echo "Successfully wrote your Email to the file.";
}

if(!$passWord)
{
echo "Please enter your password.";
exit;
}
else
{
$filename = "userpass.txt";
$content = "$passWordn";
$fp = fopen($filename, "a");
$fw = fwrite( $fp, $content );
fclose( $fp );
if(!$fw) echo "<BR><BR>Couldn't write the password entry.";
else echo "<BR><BR>Successfully wrote your Password to the file.";
}
?>[/code]


[URL=http://www.xpixal.com/test/test/input.php]input.php[/URL]

[URL=http://www.xpixal.com/test/test/userlist.txt]userlist.txt[/URL]

[URL=http://www.xpixal.com/test/test/userpass.txt]userpass.txt[/URL]
Copy linkTweet thisAlerts:
@russellkainauthorJan 30.2006 — that works a treat but i need to write both username and password to one file in this format:-

[B]userlist.txt[/B]

USERNAME1

PASSWORD1

USERNAME2

PASSWORD2

and so on....

thanks

Russell
Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYJan 30.2006 — don't store the password, but the hashed/encrypted password
Copy linkTweet thisAlerts:
@russellkainauthorJan 30.2006 — i just want to store standard text for now. It doesnt need to be encrypted just yet as i will be hosting the file on a private server which i have complete control over. and can ban access by IP.

thanks,

Russell

on that note, any ideas?
Copy linkTweet thisAlerts:
@russellkainauthorJan 30.2006 — just to clarify, i need the php file to write both sets of data to the text file, like this:-

emailaddress1

password1

and so on....
Copy linkTweet thisAlerts:
@LiL_aaronJan 30.2006 — understood... one moment please ?
Copy linkTweet thisAlerts:
@LiL_aaronJan 30.2006 — Hi

input.php

[code=php]<?
echo '<html>
<head>
<title>Subcribe</title>
</head>
<body>
<form name="subscribe" action="submit.php" method="POST">
Enter your email address : <input type="text" name="emailadd" /><br
/>
Enter your password : <input type="text" type=password name="password" /><br
/>
<input type="submit" name="submit" value="Subscribe" />
</form>
</body>
</html>';
?>[/code]


Submit.php

[code=php]<?php

$emailAddress = $_POST['emailadd'];
$passWord = $_POST['password'];

if(!$emailAddress)
{
echo "Please enter your email address.";
exit;
}
else
{
$filename = "userlist.txt";
$contente = "$emailAddressn";
$fp = fopen($filename, "a");
$fw = fwrite( $fp, $contente);
fclose( $fp );
if(!$fw) echo "Couldn't write the entry.";
else echo "Successfully wrote to the file.";
}

if(!$passWord)
{
echo "Please enter your password.";
exit;
}
else
{
$filename = "userlist.txt";
$contentp = "$passWordn";
$fp = fopen($filename, "a");
$fw = fwrite( $fp, $contentp );
fclose( $fp );
if(!$fw) echo "<BR>Couldn't write the entry.";
else echo "<BR>Successfully wrote to the file.";
}

?>[/code]


Script working:

[URL=http://www.xpixal.com/test/test/input.php]input.php[/URL]

[URL=http://www.xpixal.com/test/test/userlist.txt]userlist.txt[/URL]
Copy linkTweet thisAlerts:
@russellkainauthorJan 31.2006 — Brilliant! Thats working fine, just what I wanted.

thanks guys,

Russell
×

Success!

Help @russellkain spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...