1 Replies - 330 Views - Last Post: 13 April 2016 - 07:50 PM

#1 pidgeonpancakes   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 10-August 11

Cannot use PHP script to write to a specific space in my SHTML file

Posted 13 April 2016 - 07:40 PM

I am trying to write something that displays the text "Dave Jones" in the div class "someone" in my SHTML file from an external PHP file. It should do this on loading the SHTML page initially but if someone submits a name from the form the text "Dave Jones" is replaced with the name submitted from the form using the same PHP file.

Things I can't figure out:
1. How do I target the div to accept the data from the PHP file?
2. What can I use as an if() condition in the PHP file when the submit button is used from the form?

This is all very confusing for me.....

Bit of the SHTML code:
  <b><u>Best Customer of the Week!</u></b>
  <br>
  <div class="somename">
    <?php include('name.php');?>
  </div>  
  <br><br>
  Psssssss......
  <br>
  If you want to be the best customer of the week just enter your name here
  and click 'I'm the best customer!':
  <br>
  <form role="form" method="post" action="name.php">
  Your Name: <input type="text" name="yourname">
  <input type="submit" value="I'm the best customer!">
  </form>



My incomplete PHP code:
<?php
  
echo ("<p>Dave Jones</p>");

if () {
  $name = $_POST['yourname'];
  echo ("<p>$name</p>");
}

?>



Is This A Good Question/Topic? 0
  • +

Replies To: Cannot use PHP script to write to a specific space in my SHTML file

#2 xclite   User is offline

  • I wrote you an code
  • member icon


Reputation: 1282
  • View blog
  • Posts: 4,091
  • Joined: 12-May 09

Re: Cannot use PHP script to write to a specific space in my SHTML file

Posted 13 April 2016 - 07:50 PM

Duplicate:
http://www.dreaminco...-my-shtml-file/
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1