![]() |
|
help me with my code - Printable Version +- Sinisterly (https://sinister.li) +-- Forum: Coding (https://sinister.li/Forum-Coding) +--- Forum: PHP (https://sinister.li/Forum-PHP) +--- Thread: help me with my code (/Thread-help-me-with-my-code) |
help me with my code - yuyboy - 04-08-2014 Hi all. I make php code for sendig mail but i need to make the sucsess message and the erorr message with java secript. Code: <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>
<html><heade><meta http-equiv=”refresh” content=”0;url=http://”></head><body>
<?php
$to = "name@ex.com";
$subject = "New Message";
$name = $_POST['name'];
$email = "";
$message = $_POST['message'];
$e_mail = $_post['e_mail'];
$formcontent="name: $name \n--------------------------\nEmail: $email \n------------------------\n message: $message";
if (mail($to, $subject, $formcontent)) {
echo ("<p>Thank You!!<br>Email successfully sent!<p><br>" . "<a href='index.html' style='text-decoration:none;color:#ff0099;'>Click here to Return to Home..</a></body></html>");
} else {
echo ("<p>Failed!! please try again..<p><br>" . "<a href='index.html' style='text-decoration:none;color:#ff0099;'>Click here to Return to Home..</a>");
}
?>
</body></html>my code working as good but as i say before i need to make the sucsess message and the erorr message with java secript. please edit my code and help me as you can. best regards RE: help me with my code - The cyborg - 04-09-2014 Hi, use <script> tag inside echo command to call your success function which is defined in your <head> section. echo "<script>success();</script>"; RE: help me with my code - yuyboy - 04-10-2014 (04-09-2014, 09:46 AM)The cyborg Wrote: Hi, please edit my code and do what you mean then post the new code. RE: help me with my code - The cyborg - 04-11-2014 Hi, sorry i just can't write the whole from my cellphone keyboard so i will just show the code of success() and error() function Code: <head> // your head section
<script>
function successmsg(){
document.write("your mail is successfully sent");
}
function errormsg(){
document.write("error");
}
</script>then move to your IF condition and write inside your ECHO Code: echo "<script> successmsg(); </script>";Code: echo "<script> errormsg();</script>";hope this will help you RE: help me with my code - yuyboy - 04-12-2014 Thanks i will try it RE: help me with my code - Sir12 - 07-18-2014 May I ask how long you're coding? It is really sloppy. You need to ordering your tags. ''<headE> doesn't exist. Don't put every single code in one line, that isn'y netty. ''<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>'' is wrong. Maybe you should try this: PHP Code: <!DOCTYPE html>
<type lang="en">
<html>
''body'' means, every single detail ON the website. And ''head'' means you put every single detail what don't belong on the website, like your title or some jQuery-tags. You close your head after you've putted your Title and maybe some jQuery-shit in it. At the end of your script you put </body> ENTER </html>. Maybe it doesn't work, 'cause your code is a twin of Spaghetti. RE: help me with my code - testardube - 09-10-2014 you can try this sample code <html> <head> <title>Sample</title> <script type="text/javascript"> function sample(){ alert(1); } </script> </head> <body> <?php echo '<script type="text/javascript">sample();</script>'; ?> </body> </html> RE: help me with my code - testardube - 09-10-2014 you can try this sample code <html> <head> <title>Sample</title> <script type="text/javascript"> function sample(){ alert(1); } </script> </head> <body> <?php echo '<script type="text/javascript">sample();</script>'; ?> </body> </html> |