FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


whats wrong with this php script?





m-productions
The following is a code that, has some fields to fill out, then when you hit the button, it e-mails them all to my address, it use to work, but it no longer does, how could somthing..just stop working?

Code:

<?php
if(!isset($_POST['name'],$_POST['games'],$_POST['reason'])){
echo("<center><h1> Request an Account</h1></center>");

}else if( (!empty($_POST['name']))&& (!empty($_POST['games'])) && (!empty($_POST['reason'])) ){

$name_ = addslashes($_POST['name']); $games_ = addslashes($_POST['games']); $reason_=addslashes($_POST['reason']);

$msg = "Account Name: $name_ \n";
$msg .= "E-mail address: $games_ \n";
$msg .= "Other: $reason_ \n";
$to = "molsters_soul@Yahoo.com";
$sub = "Account Request";

mail($to,$sub,$msg) ;
echo("<script> alert(\"SUCCESS!\")</script>");

} else{echo("<center><h1> All Fields Were NOT Filled in!</h1></center>");}


?>

<form action='<?echo($_SERVER['PHP_SELF']);?>' method='post'>
<input type='text' name='name' size='30'>Account Name<br>
<input type='text' name='games' size='30'>E-Mail adress<br>
<textarea name='reason' cols='23' rows='5'></textarea>
Other<br>
<input type='submit'>
</form>



DanielXP
Try this

Code:
<?php
if((!isset($_POST['name'])) || ($_POST['games']) || ($_POST['reason'])){
echo("<center><h1> Request an Account</h1></center>");
}
else
if((!isset($_POST['name'])) || (!isset($_POST['games'])) || (!isset($_POST['reason']))){
$name = addslashes($_POST['name']);
$games = addslashes($_POST['games']);
$reason = addslashes($_POST['reason']);
$msg = "Account Name: $name \n";
$msg .= "E-mail address: $games \n";
$msg .= "Other: $reason \n";
$to = "molsters_soul@Yahoo.com";
$sub = "Account Request";
mail($to,$sub,$msg) ;
echo("<script> alert(\"SUCCESS!\")</script>");
}
else
{
echo("<center><h1> All Fields Were NOT Filled in!</h1></center>");
}
?>

<form action='<?echo($_SERVER['PHP_SELF']);?>' method='post'>
<input type='text' name='name' size='30'>Account Name<br>
<input type='text' name='games' size='30'>E-Mail adress<br>
<textarea name='reason' cols='23' rows='5'></textarea>
Other<br>
<input type='submit'>
</form>
hexkid
m-productions wrote:
it use to work, but it no longer does, how could somthing..just stop working?

I see nothing wrong with your code.
That means that I'm not seeing good or that the email server on your host has been upgraded/reconfigured/deleted/... or that Yahoo is refusing mail from your host.

Can you verify other recipient addresses?
Can you try the fourth parameter to the mail() function function
Code:
mail($to,$sub,$msg, 'From: example@example.com')
m-productions
im starting to think it was the host, this code worked for over 10 months, then my host was lost.. and ive been trying new host, none of which are good, i just got done trying another new host, i uploaded that and get this error

Warning: mail(): Could not execute mail delivery program '/usr/sbin/sendmail -t -i ' in /home/www/stetho2.100webspace.net/test.php on line 15.

(thats from the newst host i just got done trying, the one right before it nothing at all happend)

im guessing its just the hosts, can anyone try it with frihost... see if it works with them..
hexkid
m-productions wrote:
can anyone try it with frihost... see if it works with them..



Here you go. (script removed)

I changed your code a little bit:

a) I added a unmagic() function.
The frih.net server is configured with magic_quotes_gpc.
b) I unmagic'd() the $_POST variables
c) I reformatted it a little bit
d) I added a highlight_file() at the end



I will remove the script tomorrow, after I wake up and remember to do so Smile
m-productions
perfect!!!!!!!! thank you very much!
and the "game" thing that was on the list, was part of another field, that i removed, i guess i removed the e-mail field and kept that one.. rofl
hexkid
m-productions wrote:
thank you very much!

You're welcome. File deleted.
Thank you for the donation.
m-productions
well i have fainly got my account here, but havnt had time to upload the script you made for me, due to the fact ive been working on the flash page itself, anyhow i uploaded it, and got this error


Warning: highlight_file(m-prod.php) [function.highlight-file]: failed to open stream: No such file or directory in /home/mproduct/domains/m-productions.frih.net/public_html/test.php on line 42

Warning: highlight_file() [function.highlight-file]: Failed opening 'm-prod.php' for highlighting in /home/mproduct/domains/m-productions.frih.net/public_html/test.php on line 42

EDIT: ROFL! as i read over my post, i see what the problem is now..i think, it says trying to find "m-prod.php" however i renamed it to test.php, i think that would be the problem, ill go change that in the code...

Edit the Edit: nvm, i now know what highlight_file() does, thats what shows you the code LOL, so i just removed it.
Agent ME
The only thing I saw wrong was nothing critical - you make it report success even when it hasn't checked if it worked. To fix, replace
Code:
mail($to,$sub,$msg) ;
echo("<script> alert(\"SUCCESS!\")</script>");

with
Code:
if(mail($to,$sub,$msg)) {
  echo("<script> alert(\"SUCCESS!\")</script>");
} else {
  echo("<script> alert(\"Failed to Send\")</script>");
}
Related topics
Running a "Hello World" php script
Connected to another part of a php script.
vBulletin Config.php script
error in my PHP script
Phoenix free PHP scripts
how can i make a php script for enter username and password?
Inserting data to MYSQL with a PHP script
[PHP] Running Cron Jobs Via PHP Script
Simple PHP script not working
PHP Script- How can we install it
I need a VERY simple php script
PHP Script needed
Logging systeem php script
Preventing bad PHP script calls
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.