Jump to content

PHP comes up blank screen after loading.

Go to solution Solved by SnowyMus,

By default, PHP doesn't output any errors for things like syntax errors, and this is necessary for security reasons. You can enable displaying errors by modifying your php's ini file.

 

The issue is that you cannot just create another <?php> to close a curly brace from a previous <?php> tag. If you delete the second php block and add a curly brace to the end of the first code block, it should display text.

 

Oh, you may want to also use code blocks when you post code to add syntax highlighting and make your code look easier to read.

I have an email form on my website, heres the html code for the form:

Spoiler

  <section class="formquote">
    <h2 class="quote">“In photography there is a reality so subtle that it becomes more real than reality.”</h2>
    <section class="formsection" id="contact">
  <h3 class="letstalk"> Let's talk.</h3>
  <h4 class="formdesc">Want to have us at your next event? Contact below!</h4>
<form class="emailForm" name="Email Form" method="post" action="contact.php" enctype="text/plain">
<input name="first" type="first" required class="formDec" id="first" placeholder="First*">
<input name="last" type="last" required class="formDec" id="last" placeholder="Last*">
<input name="email" type="email" required class="formDec" id="email" placeholder="Email*" />
<input name="subject" type="subject" required class="formDec" id="subject" placeholder="Event Type (Wedding, party, etc.)">
<input name="message" type="message" required class="formDec messageForm" id="message" placeholder="Message">
<input type="submit" class="submitForm" id="submit" value="Submit">
</form>
</section>

 

 

 

Here is the php code that loads once you click the submit button:

Spoiler

<?php
if(isset($_POST['email'])){

    // Here is the email to information    
    $email_to = "i would put my email here, but I don't want it public.";
    $email_subject = "Ultra Media Contact Form Filled Out";
    $email_from = "Ultra Media Forms";
    
    // error code
    
    function died($error){
            echo "We are sorry, but there were error(s) found with the form you submitted.";
            echo "These errors appear below.</br><br/>";
            echo $error. "<br/><br/>";
            echo "Please go back and fix these errors.<br/>";
            die();
    }
    $first = $_POST['first'];
    $first = $_POST['last'];
    $email = $_POST['email'];
    $subject = $_POST['subject'];
    $emailmessage = $_POST['message'];
    
    $error_message = "";
    $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+/.[A-Za-z] {2,4}$/';
    if(!preg_match($email_exp, $email)) {
        $error_message .= 'The  email address you have entered does not appear to be valid.';
    }
    
    function clean_string($string){
            $bad = array("content-type", "bcc:", "to:", "cc:", "href");
            return str_replace($bad, "", $string);
    }
    
    $email_message .= "First:" . clean_string($first) . "/n";
    $email_message .= "Last:" . clean_string($last) . "/n";
    $email_message .= "Email:" . clean_string($email) . "/n";
    $email_message .= "Subject:" . clean_string($subject) . "/n";
    $email_message .= "Message:" . clean_string($emailmessage) . "/n";

    $headers = 'From: ' .$email_From . "/r/n". 'Reply-To:' .
    $email. "/r/n" .
        'X-Mailer: PHP/' . phpversion();
        @mail($email_to, $email_subject, $email_message, $headers);
        ?>

Thank you for contacting Ultra Media. We will contact you shortly. <br/><br/>
Please click <a href="index.html">here</a> to go back to our home page.
<?php
}
?>

 

 

Now, what this ends up in is a literal blank white screen. Like, I put in legit information into the form, and it comes out with a blank, white screen. Nothing happens. Just blank.

 

Please note that I am running this off of my hosting service GoDaddy, and you can find what I am working on at www.ajtsolutions.com/jt/ultramedia/

Thanks for helping!

Link to comment
Share on other sites

Link to post
Share on other sites

By default, PHP doesn't output any errors for things like syntax errors, and this is necessary for security reasons. You can enable displaying errors by modifying your php's ini file.

 

The issue is that you cannot just create another <?php> to close a curly brace from a previous <?php> tag. If you delete the second php block and add a curly brace to the end of the first code block, it should display text.

 

Oh, you may want to also use code blocks when you post code to add syntax highlighting and make your code look easier to read.

Link to comment
Share on other sites

Link to post
Share on other sites

3 minutes ago, Kavawuvi said:

By default, PHP doesn't output any errors for things like syntax errors, and this is necessary for security reasons. You can enable displaying errors by modifying your php's ini file.

 

The issue is that you cannot just create another <?php> to close a curly brace from a previous <?php> tag.

Thanks Kavawuvi. When I looked up how to create this file I was informed to do that, I don't know why.

 

But now that it works fine and it says that the form has been sent, I don't actually get any email...

Link to comment
Share on other sites

Link to post
Share on other sites

8 minutes ago, jttiglao said:

Thanks Kavawuvi. When I looked up how to create this file I was informed to do that, I don't know why.

 

But now that it works fine and it says that the form has been sent, I don't actually get any email...

PHP can't send email on its own. Do you have the email server set up in your PHP configuration?

 

If you don't, you can alternatively set these things using ini_set before sending the email before calling mail(), though some of these settings are OS-specific.

 

i.e.

ini_set("SMTP", "smtp.whatever.net");
ini_set("smtp_port", 25);
mail(...);

 

Link to comment
Share on other sites

Link to post
Share on other sites

9 minutes ago, Kavawuvi said:

PHP can't send email on its own. Do you have the email server set up in your PHP configuration?

 

If you don't, you can alternatively set these things using ini_set before sending the email before calling mail().

 

i.e.


ini_set("SMTP", "smtp.whatever.net");
ini_set("smtp_port", 25);
mail(...);

 

Is this all I need or would I have to create an email address, or use one of my emails? I used 2 ini_set variables, for the smtp server and port, would that be all I need?

I really appreciate your help, and sorry for so many questions, php is NOT one of my fortes.

Link to comment
Share on other sites

Link to post
Share on other sites

6 minutes ago, jttiglao said:

Is this all I need or would I have to create an email address, or use one of my emails? I used 2 ini_set variables, for the smtp server and port, would that be all I need?

I really appreciate your help, and sorry for so many questions, php is NOT one of my fortes.

I was assuming that setting it in the header should often be good enough. You can also set sendmail_from, but if the 'from' email is correctly set, I think it should work. I've never really done much with email in PHP before, so I'm just going by whatever the PHP manual stuff says. http://php.net/manual/en/function.mail.php

Link to comment
Share on other sites

Link to post
Share on other sites

5 minutes ago, Kavawuvi said:

I was assuming that setting it in the header should often be good enough. You can also set sendmail_from, but if the 'from' email is correctly set, I think it should work. I've never really done much with email in PHP before, so I'm just going by whatever the PHP manual stuff says. http://php.net/manual/en/function.mail.php

Alright. I just wanted to say how helpful you've been to me. I've posted so many forums on linustechtips.com, and usually after a couple back and forth conversations, the person tryna help me out always gets tired of questions and just leaves me there. Thanks!

 

Solved.

 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×