PHP noob question 03-31-2017, 01:18 PM
#1
Sry for the question guys but you don't learn unless you dare to ask those questions .
my problem is using document.getElementById in php .
First of all i wanna ask if it could be used in php.
now i'll share what i'm trying to do :
what i'm trying to do is if after submit of the form the first name and last name are the same change the lastname value to 3.
i'm having the following error :
Parse error: syntax error, unexpected '=' in C:\xampp\htdocs\test\test2.php on line 20
line 20 is the line where i used document.getElementById
my problem is using document.getElementById in php .
First of all i wanna ask if it could be used in php.
now i'll share what i'm trying to do :
Code:
<!DOCTYPE html>
<html>
<body>
<form action="test2.php" method="post">
First name:<br>
<input type="text" name="firstname" value="Mickey">
<br>
Last name:<br>
<input type="text" id="1" name="lastname" value="Mouse">
<br><br>
<input type="submit" value="Submit">
</form>
<?php
if($_SERVER["REQUEST_METHOD"]=="POST"){
if ($_POST["firstname"] == $_POST["lastname"]) {
document.getElementById("1").value="3";
echo "hi";
}}
?>
<p>If you click the "Submit" button, the form-data will be sent to a page called "/action_page.php".</p>
</body>
</html>what i'm trying to do is if after submit of the form the first name and last name are the same change the lastname value to 3.
i'm having the following error :
Parse error: syntax error, unexpected '=' in C:\xampp\htdocs\test\test2.php on line 20
line 20 is the line where i used document.getElementById
Everyone should learn how to code, it teaches you how to think.
You don't have to be a Genius to know how to code you just need to be determined.
The computer is incredibly fast, accurate, and stupid; man is unbelievably slow, inaccurate, and brilliant; together they are powerful beyond imagination.




![[+]](https://sinister.li/images/modern/collapse_collapsed.png)







![[Image: oAqtc2l.png]](https://i.imgur.com/oAqtc2l.png)




![[Image: 9H83e18.png]](https://i.imgur.com/9H83e18.png)