Click here to Skip to main content
14,580,039 members
Rate this:
Please Sign up or sign in to vote.
See more:
I'm writing a php file and I think that the language isn't defined in the document, but I'm not sure. Is there a way to define php in a file? It's been a while since I used php, but everything in the file works except the php part.

When I press the submit button, the url shows the variable names and values correctly from the get of the form. However, when it goes to the php part, it's printing "0" and not "here" and the values like it should. That's why I think there's a php language recognition problem. The w3 validator is having issues with the php open delimeter.

This is what BigTable.php looks like.

As a side note, why does this website always convert my <'s to $lt;? It's really tough to look at. Is there any way around it?

<!DOCTYPE html>
<html lang="en" >
<head>
    
<meta charset="utf-8" /> 
    <title>Big Table</title>
   
            
    <script type="text/javascript" src="js/jquery-1.11.0.js"></script>
    
   //there's some javascript that I'm not sure if I'm going to use yet here    
</head>
<body>  
    <h1> Visual Evaluation Entry Table </h1>
    <form method="get" action="BigTable.php">
<table id="bigTable" border="1">
    <thead>
     <tr>
       <th id="bandY" class="col3">Bands @263mm Y</th><th id="bandM" class="col3">Bands @263mm M</th><th id="bandC" class="col3">Bands @263mm C</th><th id="bandK" class="col3">Bands @263mm K</th><th id="Comments" class="col3">Comments</th>
     </tr>
    </thead>
    <tbody>
        <tr >
            <td><input name="bandY" ></td> <!-- //Row 0 Column 1-->
            <td><input name="bandM" ></td>  <!--//Row 0 Column 2-->
            <td><input name="bandC" ></td>  <!--//Row 0 Column 3-->
            <td><input name="bandK" ></td>  <!--//Row 0 Column 4-->
            <td><input name="comment" ></td>  <!--//Row 0 Column 4-->
        </tr>
    </tbody>
 
</table>
  <input id="submit" type="submit" class="list" name="submit" value="Submit To Database" >  
   
   <?php
//this part doesn't seem to be working. Document isn't validating on w3 site, and echo shows "0" on screen and not "here" and doesn't show variables. Get in url shows names and correct values
    if (isset($_GET['submit'])){
        $bandY= $_GET['bandY'];
        $bandM= $_GET['bandM'];
        $bandC= $_GET['bandC'];
        $bandK= $_GET['bandK'];
        $comment=$_GET['comment'];
        
        echo "here:"+$bandY+$bandM+$bandC+$bandK+$comment;
    }
   ?>
   </form>
</body>

</html>



I've been following this example on the internet, but can't find anything for how to define or check the definition of php:


http://tangledindesign.com/how-to-create-a-contact-form-using-html5-css3-and-php/#comment-1428428110[^]
Posted

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

First of all, there is nothing wrong with PHP language. Two mistakes:
1.
echo "here:"+$bandY+$bandM+$bandC+$bandK+$comment;

should be
echo "here:".$bandY.$bandM.$bandC.$bandK.$comment;

in php, dot '.' is used to concatenate strings, '+' used in javascript for this purpose.
2. The following comment
//there's some javascript that I'm not sure if I'm going to use yet here 

should be
<!-- there's some javascript that I'm not sure if I'm going to use yet here -->

See that you are learning hard. Good effort.
   
v3
Comments
MichCl 11-Jun-14 13:19pm
   
Thank you so much! I couldn't figure out what was going on in the php without that print statement so I thought it was the language!! :)
Peter Leow 12-Jun-14 7:51am
   
You are welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100