th2mods Posted August 5, 2008 Share Posted August 5, 2008 So i'm trying to get this form to work correctly. Basically, users submit information, and it sends it to me. The first file works, but the file that send the info just shows the php code... Here it is uploaded so you can see what i mean, http://forgerealm.com/test/buy.html Please take some time to look though the code, thanks. Buy2.html <html> <head> <?php if ($user->data['user_id'] == ANONYMOUS) { login_box('', $user->lang['LOGIN']); } $submit = (!empty($_POST['submit'])) ? true : false; if($submit) { $to = "christian1541@hotmail.com"; $subject = $_POST['vapplication']; $gamertag_field = $_POST['gamertag']; $accountname_field = $_POST['accountname']; $video_field = $_POST['video']; $message = $_POST['message']; $account = $_POST['filmer']; $email = $_POST['email']; $slot = $_POST['slot']; $body = "YouTube Video Application Filmer: $account\n Contact E-mail: $email\n Gamer Tag: $gamertag_field\n Forge Guide Account: $accountname_field\n Link to video: $video_field\n Slot in Fileshare: $slot\n Body: $check_msg $message\n" <? </head> </html> Buy.html <!-- INCLUDE overall_header.html --> <div style="font-size:20px;font-weight:bold;">Youtube Video Application</div> <div class="panel"> <div class="inner"><span class="corners-top"><span></span></span> <div class="content"> <p> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <body style="font-family:verdana;font-size:10px;"><script language="JavaScript"> <!-- function formCheck(formobj){ // Enter name of mandatory fields var fieldRequired = Array("gamertag", "message", "accountname", "video", "email"); var fieldDescription = Array("gamertag", "accountname", "message", "video", "email"); // dialog message var alertMsg = "Please fill out the following:\n"; var l_Msg = alertMsg.length; for (var i = 0; i < fieldRequired.length; i++){ var obj = formobj.elements[fieldRequired[i]]; if (obj){ switch(obj.type){ case "select-one": if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){ alertMsg += " - " + fieldDescription[i] + "\n"; } break; case "select-multiple": if (obj.selectedIndex == -1){ alertMsg += " - " + fieldDescription[i] + "\n"; } break; case "text": case "textarea": if (obj.value == "" || obj.value == null){ alertMsg += " - " + fieldDescription[i] + "\n"; } break; default: } if (obj.type == undefined){ var blnchecked = false; for (var j = 0; j < obj.length; j++){ if (obj[j].checked){ blnchecked = true; } } if (!blnchecked){ alertMsg += " - " + fieldDescription[i] + "\n"; } } } } if (alertMsg.length == l_Msg){ return true; }else{ alert(alertMsg); return false; } } // --> </script> <form name="formcheck" onSubmit="return formCheck(this);" method="POST" action="buy.php"> <br/><br/> <table><td> <big><b>Subject:</big></b></div><br/> <select name="vapplication" id="vapplication" class="info"><option>Youtube Video</option></select> </td></table> <br/> <br/> <br/><br/> <table><td> <big><b>Upload to what account?:</big></b></div><br/> <select name="filmer" id="filmer" class="info"><option>Halo3Forge</option></select> </td></table> <br/> <br/> <table><td> <big><b>ForgeGuide.com Account Name:</big></b></div><br/> <font size="2">If none, click <a href="http://forgeguide.com/ucp.php?mode=register" title"click">here</a> to register.</font><br/> <input type="text" name="accountname" class="post"> </td></table> <br/> <br/> <table><td> <big><b>Contact E-mail:</big></b></div><br/> <font size="2">If it is easier for us to contact you via email, instead of PM. Please fill this out.</font><br/> <input type="text" name="email" class="post"> </td></table> <br/> <br/> <table><td> <big><b>Gamer Tag:</big></b><br/> <font size="2">Xbox Live Gamer Tag.</font><br/> <input type="text" name="gamertag" class="post"> </td></table> <br/> <br/> <table><td> <big><b>Link to video:</big></b><br/> <font size="2">Link to video you want on youtube.</font><br/> <input type="text" name="video" class="post"> </td></table> <br/> <br/> <table><td> <big><b>Slot in Fileshare:</big></b><br/> <font size="2">If the video link is direct link to the bungie.net forums, dont fill this slot out.</font><br/> <input type="text" name="slot" class="post"> </td></table> <br/> <br/> <table><td> <big><b>Message:</b></big><br/> <font size="2">Tell us about yourself and why you want your video on youtube.</font><br/> <textarea style="width:320px;height:100px;" name="message" class="btnbbcode"></textarea> </td></table> <br/><br/> <table><td> <input type="submit" value="Submit" name="submit" class="btnmain"> </td></table> </form> </body> </p> </div> <span class="corners-bottom"><span></span></span></div> </div> <script type="text/javascript"><!-- google_ad_client = "pub-1044260927340270"; /* 728x90, created 4/23/08 */ google_ad_slot = "7899638539"; google_ad_width = 728; google_ad_height = 90; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> <!-- INCLUDE overall_footer.html --><div class="panel"> <div class="inner"><span class="corners-top"><span></span></span> <div class="content"> <p> Quote Link to comment https://forums.phpfreaks.com/topic/118224-solved-why-isnt-this-working/ Share on other sites More sharing options...
abdfahim Posted August 5, 2008 Share Posted August 5, 2008 why ur php end tag in Buy.php look like this "<?". It should look like "?>". [] Quote Link to comment https://forums.phpfreaks.com/topic/118224-solved-why-isnt-this-working/#findComment-608425 Share on other sites More sharing options...
th2mods Posted August 5, 2008 Author Share Posted August 5, 2008 why ur php end tag in Buy.php look like this "<?". It should look like "?>". [] now it just goes into white screen <html> <head> <?php $submit = (!empty($_POST['submit'])) ? true : false; if($submit) { $to = "christian1541@hotmail.com"; $subject = $_POST['vapplication']; $gamertag_field = $_POST['gamertag']; $accountname_field = $_POST['accountname']; $video_field = $_POST['video']; $message = $_POST['message']; $account = $_POST['filmer']; $email = $_POST['email']; $slot = $_POST['slot']; $body = "YouTube Video Application Filmer: $account\n Contact E-mail: $email\n Gamer Tag: $gamertag_field\n Forge Guide Account: $accountname_field\n Link to video: $video_field\n Slot in Fileshare: $slot\n Body: $check_msg $message\n" ?> </head> </html> Quote Link to comment https://forums.phpfreaks.com/topic/118224-solved-why-isnt-this-working/#findComment-608430 Share on other sites More sharing options...
abdfahim Posted August 5, 2008 Share Posted August 5, 2008 <<<< I truncate the body. Please see next post.>>>> Quote Link to comment https://forums.phpfreaks.com/topic/118224-solved-why-isnt-this-working/#findComment-608432 Share on other sites More sharing options...
abdfahim Posted August 5, 2008 Share Posted August 5, 2008 Hey man, u missed some semicolon and bracket stuff. Try the one below. <?php if($_POST['submit']) { $to = "christian1541@hotmail.com"; $subject = $_POST['vapplication']; $gamertag_field = $_POST['gamertag']; $accountname_field = $_POST['accountname']; $video_field = $_POST['video']; $message = $_POST['message']; $account = $_POST['filmer']; $email = $_POST['email']; $slot = $_POST['slot']; $body = "YouTube Video Application Filmer: $account\n Contact E-mail: $email\n Gamer Tag: $gamertag_field\n Forge Guide Account: $accountname_field\n Link to video: $video_field\n Slot in Fileshare: $slot\n Body: $check_msg $message\n"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/118224-solved-why-isnt-this-working/#findComment-608434 Share on other sites More sharing options...
th2mods Posted August 5, 2008 Author Share Posted August 5, 2008 still get white screen :/ Quote Link to comment https://forums.phpfreaks.com/topic/118224-solved-why-isnt-this-working/#findComment-608436 Share on other sites More sharing options...
abdfahim Posted August 5, 2008 Share Posted August 5, 2008 Man, I donno wat r u talking abt. Its totally working on me ! Plz check again. Btw, I hope you did rename ur php page as buy.php because its the name written on your form action ! Quote Link to comment https://forums.phpfreaks.com/topic/118224-solved-why-isnt-this-working/#findComment-608443 Share on other sites More sharing options...
BioBob Posted August 5, 2008 Share Posted August 5, 2008 Change: action="buy2.html" to action="buy2.php" and rename buy2.html to buy2.php... Quote Link to comment https://forums.phpfreaks.com/topic/118224-solved-why-isnt-this-working/#findComment-608472 Share on other sites More sharing options...
th2mods Posted August 5, 2008 Author Share Posted August 5, 2008 Change: action="buy2.html" to action="buy2.php" and rename buy2.html to buy2.php... yea i already did that. it redirects to buy2.html, but it just stays white Quote Link to comment https://forums.phpfreaks.com/topic/118224-solved-why-isnt-this-working/#findComment-608885 Share on other sites More sharing options...
DeanWhitehouse Posted August 5, 2008 Share Posted August 5, 2008 add error_reporting(E_ALL); to the top of both php pages Quote Link to comment https://forums.phpfreaks.com/topic/118224-solved-why-isnt-this-working/#findComment-608888 Share on other sites More sharing options...
rilana Posted August 5, 2008 Share Posted August 5, 2008 How about if you change Buy.html to Buy.php Quote Link to comment https://forums.phpfreaks.com/topic/118224-solved-why-isnt-this-working/#findComment-608910 Share on other sites More sharing options...
th2mods Posted August 5, 2008 Author Share Posted August 5, 2008 How about if you change Buy.html to Buy.php tried, doesn;t work add error_reporting(E_ALL); to the top of both php pages got nothing Quote Link to comment https://forums.phpfreaks.com/topic/118224-solved-why-isnt-this-working/#findComment-608917 Share on other sites More sharing options...
DarkWater Posted August 5, 2008 Share Posted August 5, 2008 Yeah, of course you'll get nothing. You don't actually echo anything. Try adding: echo "Testing!"; To the end of that PHP code (inside of the php tags). Quote Link to comment https://forums.phpfreaks.com/topic/118224-solved-why-isnt-this-working/#findComment-608986 Share on other sites More sharing options...
th2mods Posted August 5, 2008 Author Share Posted August 5, 2008 Man, I donno wat r u talking abt. Its totally working on me ! please check again. Btw, I hope you did rename ur php page as buy.php because its the name written on your form action ! Do you think you can give me those 2 files that you said worked for you? cause i did what you told me to do, and it still doesn't work Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/118224-solved-why-isnt-this-working/#findComment-608988 Share on other sites More sharing options...
th2mods Posted August 5, 2008 Author Share Posted August 5, 2008 Yeah, of course you'll get nothing. You don't actually echo anything. Try adding: echo "Testing!"; To the end of that PHP code (inside of the php tags). so the forms actualy working when i get a white screen? But when i check my e-mail, i dont see anything Quote Link to comment https://forums.phpfreaks.com/topic/118224-solved-why-isnt-this-working/#findComment-608993 Share on other sites More sharing options...
DarkWater Posted August 5, 2008 Share Posted August 5, 2008 Well you never called the mail() function, now did you? =P Quote Link to comment https://forums.phpfreaks.com/topic/118224-solved-why-isnt-this-working/#findComment-608994 Share on other sites More sharing options...
th2mods Posted August 5, 2008 Author Share Posted August 5, 2008 Well you never called the mail() function, now did you? =P This? $submit = (!empty($_POST['submit'])) ? true : false; or this? if(mail($to, $subject, $body)) and how would i echo it to tell the user that it was sent sucessfully, but only show that message if it was actulay succesfull? Quote Link to comment https://forums.phpfreaks.com/topic/118224-solved-why-isnt-this-working/#findComment-608995 Share on other sites More sharing options...
DeanWhitehouse Posted August 5, 2008 Share Posted August 5, 2008 if(mail($to, $subject, $body)) { echo "Success";//this only says that it is sent, not that it is recieved } Quote Link to comment https://forums.phpfreaks.com/topic/118224-solved-why-isnt-this-working/#findComment-608999 Share on other sites More sharing options...
th2mods Posted August 5, 2008 Author Share Posted August 5, 2008 well i got this code working... <?php $submit = (!empty($_POST['submit'])) ? true : false; if($_POST['submit']) { $to = "christian1541@hotmail.com"; $subject = $_POST['vapplication']; $gamertag_field = $_POST['gamertag']; $accountname_field = $_POST['accountname']; $video_field = $_POST['video']; $message = $_POST['message']; $account = $_POST['filmer']; $email = $_POST['email']; $slot = $_POST['slot']; $body = "YouTube Video Application Filmer: $account\n Contact E-mail: $email\n Gamer Tag: $gamertag_field\n Forge Guide Account: $accountname_field\n Link to video: $video_field\n Slot in Fileshare: $slot\n Body: $check_msg $message\n"; if(mail($to, $subject, $body)) { $msg = "This message has been sent successfully. Expect a response within twenty four hours."; trigger_error($msg . '<br /><br />' . sprintf($user->lang['RETURN_PORTAL'], '<a href="' . $redirect . '">', '</a>')); } else { $msg = "Message Error: Go Back and Try Again"; trigger_error($msg . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'), E_USER_WARNING); } } ?> but now is i get this in the browser Notice: This message has been sent successfully. Expect a response within twenty four hours. in /home/american/public_html/test/buy2.php on line 30 it sends though Quote Link to comment https://forums.phpfreaks.com/topic/118224-solved-why-isnt-this-working/#findComment-609000 Share on other sites More sharing options...
DarkWater Posted August 5, 2008 Share Posted August 5, 2008 Because you're using trigger_error()... O_O Quote Link to comment https://forums.phpfreaks.com/topic/118224-solved-why-isnt-this-working/#findComment-609002 Share on other sites More sharing options...
th2mods Posted August 5, 2008 Author Share Posted August 5, 2008 Because you're using trigger_error()... O_O well when i take it out the form doesn't work sorry im still learning php Quote Link to comment https://forums.phpfreaks.com/topic/118224-solved-why-isnt-this-working/#findComment-609009 Share on other sites More sharing options...
BioBob Posted August 6, 2008 Share Posted August 6, 2008 Well lets take a look: $1 =1; if ($a == 1) { $msg = "error msg, success"; //display an error } else { $msg = "error msg, fail"; //display an error } If the condition is true, display an error msg, else display the error msg anyway. So no matter what youre gonna display your error msg cuz youre treating something that should be handled with a print or an echo with a trigger_error so it will show you the line that trigger_error was called on. Suggest dumping your lines that call trigger_error() and just echo $msg after the nested loop. if ($a == 1) { $msg = "success"; } else { $msg = "fail"; } echo $msg; Quote Link to comment https://forums.phpfreaks.com/topic/118224-solved-why-isnt-this-working/#findComment-609091 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.