Jump to content

Recommended Posts

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>
  
  
  

Link to comment
https://forums.phpfreaks.com/topic/118224-solved-why-isnt-this-working/
Share on other sites

why ur php end tag in Buy.php look like this "<?". It should look like "?>". [:D]

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>

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";
}
?>

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.

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

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?

 

 

 

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 :D

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;

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.