I have a problem with my form linking to a php file.
<form action="yourThoughts.php" method="post">
What do you think?:
<input type="text" name="name">
</input>
<input type="submit" value="submit">
</input>
</form>
Then my php file says this:
<html>
<body>
Your thoughts are <?php echo $_POST["name"]; ?>
</body>
</html>
Can somebody please help me with the code of am I doing something wrong.
The files are saved in the same folder.
Thanks
Hello @zhounzhcrafter506528,
Seems like you can’t link the form to the php file because it can’t find the file.
You should code a form like:
<form action="..\yourThoughts.php" method="post">
What do you think?:
<input type="text" name="name">
</input>
<input type="submit" value="submit">
</input>
</form>
The two dot with the backslash is to read from the root where the file is being stored. So using this, the file should be able to find the .php file at the same place.
The file does link to the other file that I created, however the code is literally showing up, including the tags:
...
It does link properly however it seems to me that the code for my php file isn't working. Is there a tag that I should add to tell the computer that is is code, not text?
I am assuming you renamed your index.html as index.php and also you naming yourThoughts.php with the same name and file type, including uppercase.
So far there isn’t nothing wrong on the php file. I ran out of ideas
What’s left is that you aren’t running it on some server (like your local one) and that’s why you can’t see the output values from the php file.
Problem solved already, thanks though.