0

Hi Guys

I have been asked to make an online sign up sheet system by my boss. I have almost finished but have encountered a problem. To sign up to the created activity I have use a previous form to add a "page name" which is then used to generate a new html page. I now want to write to this new page with important info, such as Event name, dates, etc. I came up with a method so far to do this, as messy as it may be. However halfway through (line 88) it stops writing properly and just prints out the php code as text. I have only just learned php so that I can do this project so am not particulary good at it. Many thanks and sorry for the essay.

<html>
        <head>
        </head>

        <body>

        <?php

          ob_start();
          header("location: sign_up.php");

           $sitename = $_POST[eName];
           $title = $_POST[eName];
           $sDate = $_POST[sDate];
           $enDate = $_POST[enDate];
           $exDate = $_POST[exDate];
           $desc = $_POST[desc];
           $pName = $_POST[eName];

        $con=mysqli_connect("localhost","emuas","flgdls","EMUAS_signUp");
        // Check connection
        if (mysqli_connect_errno())
          {
          echo "Failed to connect to MySQL: " . mysqli_connect_error();
          }

        $sql="INSERT INTO TEST (EventName, StartDate, EndDate, ExpiryDate, PageName, Description)
        VALUES
        ('$_POST[eName]','$_POST[sDate]','$_POST[enDate]','$_POST[exDate]','$_POST[eName]','$_POST[desc]')";

        if (!mysqli_query($con,$sql))
          {
          die('Error: ' . mysqli_error($con));
          }


            $fileStart='<html>
           <head>
           <title>';

           $fileStTable=' </title>
           </head>
           <body>

         <table>
         <tr align="left">
         <th> ';

         $fileSDate=' </th>
         </tr>
         <tr align="left">
         <th> Start Date: ';

         $fileEnDate='</th>
         <th> End Date: ';

           $fileExDate='</th> 
         <th> Expiry Date: ';

         $fileDesc='</th>
         </tr>
         </table>
         <table id =createSheet>
         <tr align="left">
         <th> Description: ';

         $fileEnTable='</th>
         </tr>
        </table>
        ';

         $filePHP='
         <?php 
        $con=mysqli_connect("localhost","emuas","flgdls","EMUAS_signUp");
        // Check connection
        if (mysqli_connect_errno())
          {
          echo "Failed to connect to MySQL: " . mysqli_connect_error();
          }

        $sign = mysqli_query($con,"SELECT * FROM SIGN_UP_TEST ORDER BY User");

        echo "<table>
        <tr>
        <th>Name</th>
        <th>Status</th>
        <th>Comments</th>
        </tr>"; // Error occurs on this line by writing the "; and everythign after as text

        while($row = mysqli_fetch_array($sign))
          {
          echo "<tr>";
          echo "<td>" . $row["User"] . "</td>";
          echo "<td>" Attending "</td>";
          echo "<td>" . $row["Comments"] . "</td>";
          echo "</tr>"; 
          }
        echo "</table>";

        mysqli_close($con);
        ?>';

        $fileForm='
        <form action="sign_user.php">
        <table>
        <tr>
        <td> Name: <br /> <input type="text" name="User"  /> <input type="submit" value="Sign Up"/>  </td>
        </tr>
        <tr>
        <td> comments: <br /> <input type="text" name="comments" /></td>
        </tr>
        </table>
        </form>';

        $fileEnd=' </body>
           </html>';


           $fp = fopen("sign_up_sheets/$sitename.html", "w");
           fputs($fp, $fileStart);
           fputs($fp, $title);
           fputs($fp, $fileStTable);
           fputs($fp, $sitename);
           fputs($fp, $fileSDate);
           fputs($fp, $sDate);
           fputs($fp, $fileEnDate);
           fputs($fp, $enDate);
           fputs($fp, $fileExDate);
           fputs($fp, $exDate);
           fputs($fp, $fileDesc);
           fputs($fp, $desc);
           fputs($fp, $fileEnTable);
           fputs($fp, $filePHP);
           fputs($fp, $fileForm);
           fputs($fp, $fileEnd);
           fclose($fp);

        mysqli_close($con);
        ?>

        <script>
        window.alert("Your event has been created")
        </script>

        ob_end_flush();


        </body>
        </html>

Edited by bfitzgerald

1
Contributor
2
Replies
33
Views
4 Years
Discussion Span
Last Post by bfitzgerald
0

Okay turns out I just needed to write it to a .pph file rather than .html.
I'm still having a problem, as when I'm on the new page I want to see the users that have signed up for it. When I create the new page it won't load.

<html>
   <head>
   <title>Table Test 03 </title>
   </head>
   <body>

 <table>
 <tr align="left">
 <th> Table Test 03 </th>
 </tr>
 <tr align="left">
 <th> Start Date: </br>2013-12-31</th>
 <th> End Date: </br>2013-11-30</th> 
 <th> Expiry Date: </br>2011-12-31T22:59</th>
 </tr>
 </table>
 <table id =createSheet>
 <tr align="left">
 <th> Description: </br>fdsfa</th>
 </tr>
</table>

 <?php 
$con=mysqli_connect("localhost","emuas","flgdls","EMUAS_signUp");
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

 echo "<table> 
<tr> 
<th>Name</th> 
<th>Comments</th> 
</tr>";

$sign = mysqli_query($con,"SELECT * FROM SIGN_UP_TEST WHERE EventID='109' ORDER BY User");

while($row = mysqli_fetch_array($sign))
  {
  echo "<tr>";
  echo "<td>" . $row["User"] . "</td>";
  echo "<td>" . $row["Comments"] . "</td>";
  echo "</tr>";
  }
  }
echo "</table>";

mysqli_close($con);
?>
<form action="sign_user.php" method="post">
<input type="hidden" name="id" value="109" />
<table>
<tr>
<td> Name: <br /> <input type="text" name="user" /> </td>
</tr>
<tr>
<td> Comments: <br /> <input type="text" name="comments" /> <input type="submit" value="Sign Up"/>  </td>
</tr>
</table>
</form> </body>
   </html>
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.