Jump to content

Lee-Bartlett

Members
  • Posts

    225
  • Joined

  • Last visited

    Never

Posts posted by Lee-Bartlett

  1. Is this more cleaned up ?

     

    <?php 
    echo "<form action="'.basename($_SERVER['PHP_SELF']).'" method="POST">"; (this is line 57)
    echo "<input type=\"hidden\" name=\"id\" value=\" . $row['id'] . \">";
    echo "<td> <input type=\"submit\" value=\"update\" name=\"updatebutton\" > </td>"; 
    echo "<td> <input type=\"submit\" value=\"update\" name=\"updatebutton\" > </td>";
    echo "<td><input type=\"submit\" value=\"delete\" name=\"deletebutton\" > </td>";
    echo "</form></td>";
    echo "</tr>";
    ?>

     

    error message im getting is

     

     

    Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /home/nexodom/public_html/website/admin/du.php on line 57

  2. maq there is only one problem with it being html, when i generate a new row in my database, that doesnt get the html in it, so it is pointless doing it in html, cause i need an update and a delete button in each row. Unless there is a way to do this with html then ofc ill happily do it

  3. now im getting

    Parse error: syntax error, unexpected '<' in /home/nexodom/public_html/website/admin/du.php on line 57

     

    the relvent bits of code, the post in method is in black and i dont think its ment to stay that colour in my text editor, its ment to be grey

     

    <?php
    echo <form action="'.basename($_SERVER['PHP_SELF']).'" method="POST">
    echo '<input type="hidden" name="id" value="' . $row['id'] . '">';
    echo "<td> <input type=\"submit\" value=\"update\" name=\"updatebutton\" > </td>" 
    echo "<td> <input type=\"submit\" value=\"update\" name=\"updatebutton\" > </td>"
    echo "<td><input type=\"submit\" value=\"delete\" name=\"deletebutton\" > </td>"
    echo "</form></td>"
    echo "</tr>"
    }
    ?>

  4. now i am getting

     

    Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/nexodom/public_html/website/admin/du.php on line 57

     

    on this line echo "<input type=\"hidden\" name=\"id\" value=\"'.$row['id'].'\">";

     

    happend before because i closed it i think

  5. There is a problem putting stuff outside the php tags, when the php genereates, it does a new form for each entry in the database, putting it in html tags stops that. this is what i have so far, i have unexpected t echo on line 60

     

        <?php  require_once("includes/db_connection.php"); ?>
        
        <html>
    
    <title></title>
    <style type="text/css">
    <!--
    .style1 {
    font-size: 36px;
    color: #FFFFFF;
    }
    -->
    </style>
    </head>
    
    <body>
    <table width="617" border="1" align="center" cellpadding="5" cellspacing="0" bordercolor="#000000">
      <tr>
        <td colspan="2" bgcolor="#0099FF"><p> </p>
        <p align="center" class="style1">Nexodom.com</p>      
        <p> </p></td>
      </tr>
      <tr>
        <td width="129" height="318" align="left" valign="top"><p><br>
            <a href="du.php">Delete/Update</a></p>
        </td>
        <td width="482" align="left" valign="top"><p align="center"> </p>
        
    
    
    
    <?php
    
    if(isset($_POST['id']))
    {
    	$id = $_POST['id'];
    
    	$delete = mysql_query("DELETE FROM tblbasicform WHERE id='$id'"); 
    }
    
    
    $sql = "SELECT * from tblbasicform";
    $res = mysql_query($sql) or die(mysql_error());
    
    echo "<table border=1 align=centre>";
    echo "<tr><td>id</td> <td>Name</td><td>Email</td><td>Buissnes Name</td><td>Location</td><td>Latitude</td><td>Longitude</td><td>Free or Paid</td><td>Delete</td><td>Update</td></tr>";
    while($row = MYSQL_FETCH_ARRAY($res))
    {
    echo "<tr><td>".$row['id']."</td>";
    echo "<td>".$row['name']."</td>";
    echo "<td>".$row['email']."</td>";
    echo "<td>".$row['buissnes_name']."</td>";
    echo "<td>".$row['location']."</td>";
    echo "<td>".$row['latitude']."</td>";
    echo "<td>".$row['longitude']."</td>";
    echo "<td>".$row['type']."</td>";
    echo '<form action="'.basename($_SERVER['PHP_SELF']).'" method="POST">
    <input type="hidden" name="id" value="'.$row['id'].'">';
    echo "<td> <input type=\"submit\" value=\"update\" name=\"updatebutton\" > </td>"  ( THIS IS LINE 60)
    echo "<td><input type=\"submit\" value=\"delete\" name=\"deletebutton\" > </td>"
    echo "</form></td>"
    echo "</tr>"
    }
    
    
    
    ?>
    
    
    </table><br>
    <a href="adminuserform.php">Add a new user.</a>
        
        <p> </p>
        <p> </p>
        <p> </p>
        <p> </p>
        <p> </p></td>
      </tr>
      <tr>
        <td height="20" colspan="2" bgcolor="#0099FF"> </td>
      </tr>
    </table>
    </body>
    </html>
    

  6. Maybe if i explain my scenario first, ok, I would like to have an update button on the far right of my table where all of my database is echoed. I would like to get that update button, when clicked to update that row where the update button is. For example... Name = Bob, when i click the update button i would like it to give me the option of updating bob.

     

    Atm im getting unexpected t varible on 59 but im not sure it will work if that is fixxed.

  7. Forgot to show form 3, do you mean somthing like this??

     

    <?php  require_once("includes/db_connection.php");
    
    
    $name = $_POST['name'];
    $email = $_POST['email'];
    $location = $_POST['location'];
    $type = $_POST['type'];
    $buissnes_name = $_POST['buissnes_name'];
    $id = $_POST['id'];
    
    
    $query = "UPDATE tblbasicform SET name='$name',location='$location',email='$email', buissnes_name='$buissnes_name', type='$type' WHERE id='$id'";
    $res = mysql_query($query) or die("Error: " . mysql_error());
    
    echo "Database Updated<br>";
    echo "Name $name<br>";
    echo "Email $email<br>";
    echo "Location $location<br>";
    echo "Buissnes_name $buissnes_name<br>";
    echo "Type $type<br>";
    echo "ID $id<br>";
    
    
    ?>
    
    <a href="updatedelete.php">Start Over</a>

  8. Ok here is my page, let me explain the page, its a table where all my db table is listed, on that page it has a delete button, which deletes that record and it is supposed to have an update button, which will update the record. Im not sure what im doing wrong now, I been trying get help, but from more then one place, it gets very confusing, other people have other ideas etc... So heres my code so far. Can anyone help please

     

        <?php  require_once("includes/db_connection.php"); ?>
        
        <html>
    
    <title></title>
    <style type="text/css">
    <!--
    .style1 {
    font-size: 36px;
    color: #FFFFFF;
    }
    -->
    </style>
    </head>
    
    <body>
    <table width="617" border="1" align="center" cellpadding="5" cellspacing="0" bordercolor="#000000">
      <tr>
        <td colspan="2" bgcolor="#0099FF"><p> </p>
        <p align="center" class="style1">Nexodom.com</p>      
        <p> </p></td>
      </tr>
      <tr>
        <td width="129" height="318" align="left" valign="top"><p><br>
            <a href="du.php">Delete/Update</a></p>
        </td>
        <td width="482" align="left" valign="top"><p align="center"> </p>
        
    
    
    
    <?php
    if ($_POST['updatebutton']) {
      // an update button was pressed
    }
    if ($_POST['deletebutton']) {
        
    $id = mysql_real_escape_string($_POST['id']);
      $delete = mysql_query("DELETE FROM tblbasicform WHERE id='$id'"); 
    
    }
    
    $sql = "SELECT * from tblbasicform";
    $res = mysql_query($sql) or die(mysql_error());
    
    echo "<table border=1 align=centre>";
    echo "<tr><td>id</td> <td>Name</td><td>Email</td><td>Buissnes Name</td><td>Location</td><td>Latitude</td><td>Longitude</td><td>Free or Paid</td><td>Delete</td><td>Update</td></tr>";
    while ($row=mysql_fetch_assoc($res)) {
    
    echo "<tr><td>".$row['id']."</td>";
    echo "<td>".$row['name']."</td>";
    echo "<td>".$row['email']."</td>";
    echo "<td>".$row['buissnes_name']."</td>";
    echo "<td>".$row['location']."</td>";
    echo "<td>".$row['latitude']."</td>";
    echo "<td>".$row['longitude']."</td>";
    echo "<td>".$row['type']."</td>";
    echo "<td>"<form action="form2.php'.basename($_SERVER['PHP_SELF']).'" method="POST">
      echo "<input type=\"hidden\" value=\"{$row['id']}\" name=\"id\" />";
      echo "<input type=\"submit\" value=\"update\" name=\"updatebutton\" />";
      echo "<input type=\"submit\" value=\"delete\" name=\"deletebutton\" />";
      echo "</form></td>";
    
    }
    
    echo "</tr>";
    
    echo "</table><br>"; 
    
    ?>
    
    <a href="adminuserform.php">Add a new user.</a>
        
        <p> </p>
        <p> </p>
        <p> </p>
        <p> </p>
        <p> </p></td>
      </tr>
      <tr>
        <td height="20" colspan="2" bgcolor="#0099FF"> </td>
      </tr>
    </table>
    </body>
    </html>
    

     

    And the page which makes the update bit work.

     

    <?php  require_once("includes/db_connection.php");
    
    
    $name = $_POST['name'];
    
    
    
    echo "<form action=\"form3.php\" method=\"post\">";
    $sql = "SELECT * from tblbasicform WHERE name = '$name'";
    $res = mysql_query($sql) or die(mysql_error());
    
    while($row = mysql_fetch_array($res)){
    $id = $row['id'];
    $name = $row['name'];
        $email = $row['email'];
    $buissnes_name = $row['buissnes_name'];
    $location = $row['location'];
    $type = $row['type'];
    
    ?>
    
      Input Name: <input type="text" name="name" value="<? echo $name ?>" /><br />
      Input Email: <input type="text" name="email" value="<? echo $email?>" /><br />
      Input Buissnes Name: <input type="text" name="buissnes_name" value="<? echo $buissnes_name?>" /><br />
      Input Location: <input type="text" name="location" value="<? echo $location?>" /><br />
      Input Free or Paid: <input type="text" name="type" value="<? echo $type?>" /><br />
    <input type="hidden" name="id" value="<? echo $id?>">
    <input type="submit" name="submit" value="Update Data" />
    </form>
    
    <?php
    }
    ?>
    
    

  9. That was strange, must copied wrong code, the top piece of code should look like this

     

    <?php
    
    
    //db connection
    require_once("includes/db_connection.php"); 
    //end of db connection 
    
    ?>
    <html>
    <head>
    <script type="text/javascript">
    function validate_required(name,alerttxt)
    {
            with (name)
            {
                    if (value=="")
                    {
                            alert(alerttxt);
                            return false;
                    }
                    else
                    {
                            return true;
                    }
            }
    } 
    
    
    function validate_required(buissnes_name,alerttxt)
    {
            with (buissnes_name)
            {
                    if (value=="")
                    {
                            alert(alerttxt);
                            return false;
                    }
                    else
                    {
                            return true;
                    }
            }
    }
    function validate_required(location,alerttxt)
    {
            with (location)
            {
                    if (value=="")
                    {
                            alert(alerttxt);
                            return false;
                    }
                    else
                    {
                            return true;
                    }
            }
    }
    
    function validate_email(email,alerttxt)
    {
            with (email)
            {
                    apos=value.indexOf("@");
                    dotpos=value.lastIndexOf(".");
                    if (apos<1||dotpos-apos<2)
                    {
                            alert(alerttxt);
                            return false;
                    }
                    else
                    {
                            return true;
                    }
            }
    }
    
    function validate_form(thisform)
    {
            with (thisform)
            {
                    if (validate_required(email,"Email is a required field")==false)
                    {
                            email.focus();
                            return false;
                    }
                    else if (validate_email(email,"Not a valid e-mail address!")==false)
                    {
                            email.focus();
                            return false;
                    }
                    else if (validate_required(name,"Name is a required field")==false)
                    {
                            email.focus();
                            return false;
                    }
    			    else if (validate_required(location,"Location is a required field")==false)
                    {
                            email.focus();
                            return false;
                    }
    			    else if (validate_required(buissnes_name,"Buisness Name is a required field")==false)
                    {
                            email.focus();
                            return false;
                    }
            }
    return true;
    } 
    function my_simple_validation (email)
    {
            if (email.value == '')
            {
                    alert('You must fill in required fields!');
            return false; // This is where you tell the form not to submit
            }
    
    return true; // if we pass, submit the form
    }
    
    function valbutton(thisform) {
    
    myOption = -1;
    for (i=thisform.type.length-1; i > -1; i--) {
    if (thisform.type[i].checked) {
    myOption = i; i = -1;
    }
    }
    if (myOption == -1) {
    alert("You must select a radio button");
    return false;
    }
    
    alert("You selected button number " + myOption
    + " which has a value of "
    + thisform.type[myOption].value);
    
    // place any other field validations that you require here
    thisform.submit(); // this line submits the form after validation
    }
    
    </script>
    <?php
    
    
      
    // db table connection
    include("form.php"); 
    //end of db table connection 
    ?>
    
    </head>
    
    <body>
    <form name="form" method="post" action="includes/form.php" onSubmit="return validate_form(this);"> 
    
    
    <table width="617" border="1" align="center" cellpadding="5" cellspacing="0" bordercolor="#000000">
      <tr>
        <td colspan="2" bgcolor="#0099FF"><p> </p>
        <p align="center" class="style1">Nexodom.com</p>      
        <p> </p></td>
      </tr>
      <tr>
        <td width="129" height="318" align="left" valign="top"><p><a href="index.html">Home</a><br>
            <a href="wifi.php">WIFI Hot Spots</a></p>
        </td>
        <td width="482" align="left" valign="top"><p align="center">Welcome to nexodom.com</p>
        
    
    
      
      <input type="hidden" name="redirect" value="home.php"> 
      <table width="418" align="left" cellpadding="0" cellspacing="0">
        <tr>
          <td width="222"> Name:</td>
          <td width="194"><label for="name"></label>
          <input type="text" name="name" id="name"></td>
        </tr>
        <tr>
          <td>Email:</td>
          <td><label for="email"></label>
          <input type="text" name="email" id="email"></td>
        </tr>
        <tr>
          <td>WiFi Business Name:</td>
          <td><label for="buissnes_name"></label>
          <input type="text" name="buissnes_name" id="buissnes_name"></td>
        </tr>
        <tr>
          <td>WiFi Location:</td>
          <td><label for="textfield"></label>
          <input type="text" name="location" id="location"></td>
        </tr>
      <tr>
          <td>Longitude:</td>
          <td><label for="textfield"></label>
          <input type="text" name="longitude" id="longitude"></td>
        </tr>
      <tr>
          <td>Latitude:</td>
          <td><label for="textfield"></label>
          <input type="text" name="latitude" id="latitude"></td>
        </tr>
        <tr>
          <td>Free or Paid:</td>
          <td>Free<input type="radio" name="type" id="type" value="free">
          <label for="radio"></label>
          Paid<input type="radio" name="type" id="type" value="paid">
          <label for="radio2"></label></td>
        </tr>
        <tr>
          <td> </td>
          <td><label for="button"></label>
          <input type="submit" name="button" id="button" value="Submit">
          <label for="button2"></label>
          <input type="reset" name="button2" id="button2" value="Reset">       
          <label for="sub"></label></td>
        </tr>
      </table>
    
    
    
    
    
    
        
        <p> </p>
        <p> </p>
        <p> </p>
        <p> </p>
        <p> </p></td>
      </tr>
      <tr>
        <td height="20" colspan="2" bgcolor="#0099FF"> </td>
      </tr>
    </table>
    </form>
    </body>
    </html>
    
    <?php mysql_close ?> 

  10. Ok for some reasson, not sure why, these are basically copied from my user side of my site are messing up, the files are in the correct place and the error message im getting is, Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'type) VALUES ('111sf','leebartlett18@googlemail.com','dsfsdf','sdfsafsad','fasdf' at line 1. But i dont know why, please help. everything is set up correct, db wise, db connection.php is fine etc

     

    $sql="INSERT INTO tblbasicform (name, email, buissnes_name, location,  longitude, latitude, type)
    VALUES
    ('$_POST[name]','$_POST[email]','$_POST[buissnes_name]','$_POST[location]','$_POST[longitude]','$_POST[latitude]','$_POST[type]')";
    
    if (!mysql_query($sql,$connect))
      {
      die('Error: ' . mysql_error());
      }
    

     

    <?php  require_once("includes/db_connection.php");  ?>
    <?php
    
    $sql="INSERT INTO tblbasicform (name, email, buissnes_name, location,  longitude, latitude, type)
    VALUES
    ('$_POST[name]','$_POST[email]','$_POST[buissnes_name]','$_POST[location]','$_POST[longitude]','$_POST[latitude]','$_POST[type]')";
    
    if (!mysql_query($sql,$connect))
      {
      die('Error: ' . mysql_error());
      }
    ?>
    
    <a href="du.php">Take me back to Database.</a>
    

  11. Now i tried this, move few stuff about, the @ still isnt validating, and i cant get the name to if blank say a message.

     

    <?php
    
    
    //db connection
    require_once("includes/db_connection.php"); 
    //end of db connection 
    
    ?>
    <html>
    <head>
    <script type="text/javascript">
    function validate_required(name,alerttxt)
    {
            with (name)
            {
                    if (value=="")
                    {
                            alert(alerttxt);
                            return false;
                    }
                    else
                    {
                            return true;
                    }
            }
    } 
    function validate_email(email,alerttxt)
    {
            with (email)
            {
                    apos=value.indexOf("@");
                    dotpos=value.lastIndexOf(".");
                    if (apos<1||dotpos-apos<2)
                    {
                            alert(alerttxt);
                            return false;
                    }
                    else
                    {
                            return true;
                    }
            }
    }
    
    function validate_form(thisform)
    {
            with (thisform)
            {
                    if (validate_required(email,"Email is a required field")==false)
                    {
                            email.focus();
                            return false;
                    }
                    else if (validate_email(email,"Not a valid e-mail address!")==false)
                    {
                            email.focus();
                            return false;
                    }
                    else if (validate_required(name,"Name is a required field")==false)
                    {
                            email.focus();
                            return false;
                    }
            }
    return true;
    } 
    function my_simple_validation (email)
    {
            if (email.value == '')
            {
                    alert('You must fill in required fields!');
            return false; // This is where you tell the form not to submit
            }
    
    return true; // if we pass, submit the form
    }
    </script>
    <?php
    
    if(isset($_POST['button'])) 
    {
      
    // db table connection
    include("includes/form.php"); 
    //end of db table connection 
    
    }
    ?>
    <title></title>
    <style type="text/css">
    <!--
    .style1 {
    font-size: 36px;
    color: #FFFFFF;
    }
    -->
    </style>
    </head>
    
    <body>
    <form name="form" method="post" action="includes/form.php" onsubmit="return my_simple_validation(this.email);"> 
    
    <table width="617" border="1" align="center" cellpadding="5" cellspacing="0" bordercolor="#000000">
      <tr>
        <td colspan="2" bgcolor="#0099FF"><p> </p>
        <p align="center" class="style1">Nexodom.com</p>      
        <p> </p></td>
      </tr>
      <tr>
        <td width="129" height="318" align="left" valign="top"><p><a href="index.html">Home</a><br>
            <a href="wifi.php">WIFI Hot Spots</a></p>
        </td>
        <td width="482" align="left" valign="top"><p align="center">Welcome to nexodom.com</p>
        
    
    
      
      <input type="hidden" name="redirect" value="home.php"> 
      <table width="418" align="left" cellpadding="0" cellspacing="0">
        <tr>
          <td width="157"> Name:</td>
          <td width="259"><label for="name"></label>
          <input type="text" name="name" id="name"></td>
        </tr>
        <tr>
          <td>Email:</td>
          <td><label for="email"></label>
          <input type="text" name="email" id="email"></td>
        </tr>
        <tr>
          <td>WiFi Business Name:</td>
          <td><label for="buissnes_name"></label>
          <input type="text" name="buissnes_name" id="buissnes_name"></td>
        </tr>
        <tr>
          <td>WiFi Location;</td>
          <td><label for="textfield"></label>
          <input type="text" name="location" id="location"></td>
        </tr>
        <tr>
          <td>Free or Paid:</td>
          <td>Free<input type="radio" name="type" id="type" value="free">
          <label for="radio"></label>
          Paid<input type="radio" name="type" id="type" value="paid">
          <label for="radio2"></label></td>
        </tr>
        <tr>
          <td> </td>
          <td><label for="button"></label>
          <input type="submit" name="button" id="button" value="Submit">
          <label for="button2"></label>
          <input type="reset" name="button2" id="button2" value="Reset">       
          <label for="sub"></label></td>
        </tr>
      </table>
    
    
    
    
    
    
        
        <p> </p>
        <p> </p>
        <p> </p>
        <p> </p>
        <p> </p></td>
      </tr>
      <tr>
        <td height="20" colspan="2" bgcolor="#0099FF"> </td>
      </tr>
    </table>
    </form>
    </body>
    </html>
    
    <?php mysql_close ?> 

  12. Sorry im a complete novice, i cant see where my other validation, for name, if empty i want it to return anything to let me know its working, this is my script so far.

     

    <script type="text/javascript">
    
    
    function validate_required(name,alerttxt)
    {
    with (name)
    {
      if (name==null||name=="")
      {
      alert(alerttxt);return false;
      }
      else
      {
      return true;
      }
    }
    }
    
    
    
    function validate_email(email,alerttxt)
    {
    with (email)
    {
    apos=value.indexOf("@");
    dotpos=value.lastIndexOf(".");
    if (apos<1||dotpos-apos<2) 
      {alert(alerttxt);return false;}
    else {return true;}
    }
    }
    
    function validate_form(thisform)
    {
    with (thisform)
    {
    if (validate_email(email,"Not a valid e-mail address!")==false)
      {email.focus();return false;}
    }
    }
    function my_simple_validation (email)
    {
      if (email.value == '')
      {
        alert('You must fill in required fields!');
        return false; // This is where you tell the form not to submit
      }
    
      return true; // if we pass, submit the form
    }
    </script>
    
    <form name="my_form" action="includes/form.php" method="post" onsubmit="return my_simple_validation(this.email);">
    
    </script>
    

×
×
  • 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.