8 Replies - 1022 Views - Last Post: 09 March 2016 - 07:49 PM Rate Topic: -----

#1 Shinoj_52   User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 62
  • Joined: 29-October 15

Internal Server Error 500 while running a Php script

Posted 05 March 2016 - 11:21 PM

Hello Gurus

I have coded a php script within an HTML script. It does a simple form checking on the HTML Page.However
while running the script i am getting an Internal Server Error 500..

My HTML code is down below

<html>
<head>
    
</head>
<body>
    <h2>php Form Validation Example</h2>
    <form method="post" action="check.php">
    <b>Name:</b> <input type="text" name="name"></input><font color="red">* Required field</font><br><br>
    <b>E-Mail:</b> <input type="text" name="email"></input><font color="red">* Required field</font><br><br>
    <b>Website:</b> <input type="text" name="website"></input><font color="red">* Required field</font><br><br>
    <b>Address:</b> <input type="text" name="address"></input>
    <input type="submit" name="submit"></input>
    </form>
</body>
</html>




And the attached PHP code is

<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);    
//To check the changes
echo "Going into the Loop";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if empty(($_POST['name'])) then
          echo "Name cannot be Empty";   
    endif
    if empty(($_POST)['email'])) then
          echo "E-Mail cannot be Empty";
    endif
    if empty(($_POST)['website'])) then
          echo "Website cannot be Empty";
    endif
else
    echo "Some Error";
   }
?>




Your input is required

Regards
Shinoj

Is This A Good Question/Topic? 0
  • +

Replies To: Internal Server Error 500 while running a Php script

#2 astonecipher   User is offline

  • Enterprise Software Architect
  • member icon

Reputation: 3151
  • View blog
  • Posts: 11,956
  • Joined: 03-December 12

Re: Internal Server Error 500 while running a Php script

Posted 06 March 2016 - 12:12 AM

you really need to learn the syntax for php. Look up php if statement.
Was This Post Helpful? 0
  • +
  • -

#3 Shinoj_52   User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 62
  • Joined: 29-October 15

Re: Internal Server Error 500 while running a Php script

Posted 09 March 2016 - 01:09 AM

No.. No Positive effect

<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);    
//To check the changes
echo "Going into the Loop";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if empty(($_POST['name'])) {
        echo "Name cannot be Empty";   
    }          
    if empty(($_POST)['email'])) {
        echo "E-Mail cannot be Empty";
    }     
    if empty(($_POST)['website'])) 
    {
        echo "Website cannot be Empty";
    }
}
else
{
    echo "Some Error";
}

?>



Was This Post Helpful? 0
  • +
  • -

#4 jasonmiller   User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 1
  • Joined: 09-March 16

Re: Internal Server Error 500 while running a Php script

Posted 09 March 2016 - 01:15 AM

I am not sure that it may help you in php. Anyway you should go for the try and if not then I will give you full info next time after using it. If you do not want to try then I would suggest you to use divi because it is going to help you a lot.
Was This Post Helpful? -1
  • +
  • -

#5 andrewsw   User is offline

  • palpable absurdity
  • member icon

Reputation: 6905
  • View blog
  • Posts: 28,565
  • Joined: 12-December 12

Re: Internal Server Error 500 while running a Php script

Posted 09 March 2016 - 01:46 AM

divi is completely irrelevant.

There are several basic syntax errors in the code, mainly concerning the use of parentheses. Study basic PHP syntax.
Was This Post Helpful? 1
  • +
  • -

#6 NeutralCoder   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 36
  • Joined: 11-December 15

Re: Internal Server Error 500 while running a Php script

Posted 09 March 2016 - 08:28 AM

Not sure whether this will help.Just try with changing,

if ($_SERVER["REQUEST_METHOD"] == "POST")


to

if(isset($_POST["submit"])){//Your code here}

This post has been edited by NeutralCoder: 09 March 2016 - 08:28 AM

Was This Post Helpful? 0
  • +
  • -

#7 astonecipher   User is offline

  • Enterprise Software Architect
  • member icon

Reputation: 3151
  • View blog
  • Posts: 11,956
  • Joined: 03-December 12

Re: Internal Server Error 500 while running a Php script

Posted 09 March 2016 - 09:48 AM

NeutralCoder, not the issue. The former is preferred, but you do show a proper if statement, which is one of the major issues the OP is facing.
Was This Post Helpful? 0
  • +
  • -

#8 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6876
  • View blog
  • Posts: 31,670
  • Joined: 10-May 07

Re: Internal Server Error 500 while running a Php script

Posted 09 March 2016 - 10:42 AM

When I hit 500 errors, I read the error logs & determine what the issue is as PHP determined it. Looking at the code knowing only that there is an issue leads to loss of time by guessing & making potentially unnecessary edits to code.

View PostShinoj_52, on 06 March 2016 - 01:21 AM, said:

Your input is required


My reply is based on the absolutely REQUIREMENT & I fear for my safety if I were not to oblige.
Was This Post Helpful? 1
  • +
  • -

#9 NeutralCoder   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 36
  • Joined: 11-December 15

Re: Internal Server Error 500 while running a Php script

Posted 09 March 2016 - 07:49 PM

View Postastonecipher, on 09 March 2016 - 09:48 AM, said:

NeutralCoder, not the issue. The former is preferred, but you do show a proper if statement, which is one of the major issues the OP is facing.


ok cool.And i came up with a working code for this.Since it's a small code i thought to give a try.So following code is working,

<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);    
//To check the changes
echo "Going into the Loop";
if ($_SERVER["REQUEST_METHOD"] == "POST") 
  {
    if (empty($_POST['name'])){
          echo "Name cannot be Empty";   
    }
    else if (empty($_POST['email'])) {
          echo "E-Mail cannot be Empty";
        }
    else if (empty($_POST['website'])) {
          echo "Website cannot be Empty";
        }
    else{
      echo "Some Error";
    }
  }
?>


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1