Jump to content

Quick Question


jason jollins

Recommended Posts

Hi guys,

 

I just created a new guestbook for my website and I'm running into what seems to be an easy fix that I just can't seem to figure out.

 

 

Does anyone know how I can add a "Location" field into my guestbook or how to substitute the "email" field for "Location" ?

 

My guestbook can be viewed at:  http://jasonjollins.com/guestbook/guestbooksign.php

 

 

Your help is much appreciated.

 

Thanks,

 

Jason

Link to comment
https://forums.phpfreaks.com/topic/112886-quick-question/
Share on other sites

what exactly is the problem you have?

 

 

Thanks so much for the quick response.

 

If you look on this page:  http://jasonjollins.com/guestbook/guestbooksign.php  you will see 3 fields for people to input info (Name, Email Address, Message).

 

What I want to do is have a "Location" Field so that if someone signs the guestbook from a certain country they can input where they are from.

 

Is there a way to do this?

 

 

 

 

 

-

Link to comment
https://forums.phpfreaks.com/topic/112886-quick-question/#findComment-579841
Share on other sites

Add entry

<?php

if (($_GET["add"]=="yes")){
   $strGuestbook_Name= mysql_escape_string($_POST["txtName"]);
   $strGuestbook_Email= mysql_escape_string($_POST["txtEmail"]);
   $strGuestbook_Status= "Waiting";
   $strGuestbook_Message= mysql_escape_string($_POST["txtMessage"]);

   include ("dbcon.php");
   $query = "INSERT into guestbook (guestbook_Name, guestbook_Email, guestbook_Message, guestbook_Status) VALUES ('$strGuestbook_Name','$strGuestbook_Email','$strGuestbook_Message','$strGuestbook_Status')";
   $record = mysql_query($query) or die (mysql_error());
      if ($record) {

      header ("Location: postsuccess.php");


      }
    mysql_close();

}


function listPosts()
{
include ("dbcon.php");
$query = "SELECT * FROM guestbook WHERE guestbook_Status='Approved' ORDER BY guestbook_Id DESC";
$record = mysql_query($query) or die (mysql_error());
$strHTML = "";
$modCtr = 0;

while ($row = mysql_fetch_array($record))
   {

      $strGuestbook_Id = $row['guestbook_Id'];
      $strGuestbook_Name = $row['guestbook_Name'];
      $strGuestbook_Email = $row['guestbook_Email'];
      $strGuestbook_Status = $row['guestbook_Status'];
      $strGuestbook_Message= $row['guestbook_Message'];

       $strHTML = $strHTML."<tr><td align='left'><table width='100%'  border='0' cellspacing='0' cellpadding='0'><tr>";
       $strHTML = $strHTML."<td class='txtDivider'>· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·</td>";
       $strHTML = $strHTML."</tr><tr>";
       $strHTML = $strHTML."<td class='txtMain'><strong>".$strGuestbook_Name."</strong></td>";
       $strHTML = $strHTML."</tr><tr>";
       $strHTML = $strHTML."<td><span class='txtMain'>".stripslashes($strGuestbook_Message)."</span></td>";
       $strHTML = $strHTML."</tr></table></td></tr>";

   }
   echo $strHTML;
}


?>
<HTML>
<HEAD>
<TITLE>Jason Jollins Guestbook</TITLE>
<style type="text/css">
<!--
.style1 {
   font-family: Arial, Helvetica, sans-serif;
   font-size: 12;
}
.style4 {font-size: 10px}
.style5 {font-family: Arial, Helvetica, sans-serif; font-size: 10px; }
.style7 {font-size: 14px}
-->
</style>
</HEAD>
   <BODY bgcolor=0E5A67 text=white alink=cfcffc link=FFFFFF vlink=cfcffc>
   <CENTER class="style1">
   </CENTER>

<table width="100%"  border="0" cellspacing="2" cellpadding="0">
  <tr>
    <td align="left" class="style1 style4"><CENTER>
      <H3>Guestbook</H3>
    </CENTER>
    <p class="style7">Thank you for signing my guest book!  </td>
  </tr>
  <tr>
    <td align="left" class="style5"> </td>
  </tr>
  <tr>
    <td class="style5"><form action="guestbooksign.php?add=yes" method="post" name="frmContact" class="style4" onsubmit="javascript:return ValidateField();">
        All fields are required.
        <table width="100%"  border="0" cellspacing="0" cellpadding="5">
          <tr class="txtMain">
            <td width="100" align="left">Name</td>
            <td width="10">:</td>
            <td align="left">
              <input name="txtName" type="text" id="txtName"></td>
          </tr>
          <tr class="txtMain">
            <td width="100" align="left">E-mail Address </td>
            <td width="10">:</td>
            <td align="left"><input name="txtEmail" type="text" id="txtEmail"></td>
          </tr>
          <tr class="txtMain">
            <td width="100" align="left" valign="top">Message</td>
            <td width="10" valign="top">:</td>
            <td align="left">              <textarea name="txtMessage" cols="25" rows="5" id="txtMessage"></textarea>              </td>
          </tr>
          <tr class="txtMain">
            <td width="100"> </td>
            <td width="10"> </td>
            <td align="left">
              <input type="submit" name="Submit" value="Post" >
              <input type="reset" name="Submit2" value="Reset">
            </td>
          </tr>
        </table>
    </form></td>
  </tr>
  <tr>
    <td class="style5"> </td>
  </tr>
  <tr>
    <td class="style5"><? listPosts(); ?></td>
  </tr>
  <tr>
    <td class="style1">
      </td>
  </tr>
</table>
<p class="style1">
</BODY>
</HTML>

 

Display guestbook entries

<?php

if (($_GET["add"]=="yes")){
   $strGuestbook_Name= mysql_escape_string($_POST["txtName"]);
   $strGuestbook_Email= mysql_escape_string($_POST["txtEmail"]);
   $strGuestbook_Status= "Waiting";
   $strGuestbook_Message= mysql_escape_string($_POST["txtMessage"]);

   include ("dbcon.php");
   $query = "INSERT into guestbook (guestbook_Name, guestbook_Email, guestbook_Message, guestbook_Status) VALUES ('$strGuestbook_Name','$strGuestbook_Email','$strGuestbook_Message','$strGuestbook_Status')";
   $record = mysql_query($query) or die (mysql_error());
      if ($record) {

      header ("Location: postsuccess.php");


      }
    mysql_close();

}


function listPosts()
{
include ("dbcon.php");
$query = "SELECT * FROM guestbook WHERE guestbook_Status='Approved' ORDER BY guestbook_Id DESC";
$record = mysql_query($query) or die (mysql_error());
$strHTML = "";
$modCtr = 0;

while ($row = mysql_fetch_array($record))
   {

      $strGuestbook_Id = $row['guestbook_Id'];
      $strGuestbook_Name = $row['guestbook_Name'];
      $strGuestbook_Email = $row['guestbook_Email'];
      $strGuestbook_Status = $row['guestbook_Status'];
      $strGuestbook_Message= $row['guestbook_Message'];

       $strHTML = $strHTML."<tr><td align='left'><table width='100%'  border='0' cellspacing='0' cellpadding='0'><tr>";
       $strHTML = $strHTML."<td class='txtDivider'>· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·</td>";
       $strHTML = $strHTML."</tr><tr>";
       $strHTML = $strHTML."<td class='txtMain'><strong>".$strGuestbook_Name."</strong></td>";
       $strHTML = $strHTML."</tr><tr>";
       $strHTML = $strHTML."<td><span class='txtMain'>".stripslashes($strGuestbook_Message)."</span></td>";
       $strHTML = $strHTML."</tr></table></td></tr>";

   }
   echo $strHTML;
}


?>
<HTML>
<HEAD>
<TITLE>Jason Jollins Guestbook</TITLE>
<style type="text/css">
<!--
.style1 {
   font-family: Arial, Helvetica, sans-serif;
   font-size: 12;
}
.style4 {font-size: 10px}
.style5 {font-family: Arial, Helvetica, sans-serif; font-size: 10px; }
.style7 {font-size: 14px}
.style8 {
   font-size: 12px;
   font-weight: bold;
}
-->
</style>
</HEAD>
   <BODY bgcolor=0E5A67 text=white alink=cfcffc link=FFFFFF vlink=cfcffc>
   <CENTER class="style1">
   </CENTER>

<table width="100%"  border="0" cellspacing="2" cellpadding="0">
  <tr>
    <td align="left" class="style1 style4"><CENTER>
      <H3>Guestbook</H3>
    </CENTER>
    <p class="style7">Thank you for visiting JasonJollins.com!  </td>
  </tr>
  <tr>
    <td align="left" class="style5"> </td>
  </tr>
  <tr>
    <td align="left" class="style5"><a href="guestbooksign.php" class="style1 style8">Click Here to Sign my Guest Book![/url]</td>
  </tr>
  <? listPosts(); ?>
  <tr>
    <td class="style5"> </td>
  </tr>
  <tr>
    <td class="style1">
    </td>
  </tr>
</table>
<p class="style1">
   </BODY>
</HTML>

Link to comment
https://forums.phpfreaks.com/topic/112886-quick-question/#findComment-580155
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.