Jump to content

Guteman

Members
  • Posts

    39
  • Joined

  • Last visited

    Never

Posts posted by Guteman

  1. I have been a long time user with using Dynamic SSI Iframes, but I am looking for an easier way to make a layout work. How can I make a layout with ease without having todo php includes? I want it to function like an iframe, but not actually be one.
  2. Alright now its getting somewhere, something small is still missing!

    [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]UPDATE news SET title='SST Website',post='Hello and Welcome to the SST-Website. This is the news script working.',user='Guteman' WHERE id='\".$id.\"'[/quote]

    is what i got now

    here is the full code (all 1 page)

    [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
    <?

    include("config.php");


    //If cmd has not been initialized
    if(!isset($cmd))
    {
    //display all the news
    $result = mysql_query("select id, title from news order by id");

    //run the while loop that grabs all the news scripts
    while($r=mysql_fetch_array($result))
    {
    //grab the title and the ID of the news
    $id=$r["id"];//take out the id
    $title=$r["title"];//take out the title

    //make the title a link
    echo "<a href='edit.php?cmd=edit&id=$id'>$title - Edit</a>";
    echo "<br>";
    }
    }
    ?>
    <?
    if($_GET["cmd"]=="edit" || $_POST["cmd"]=="edit")
    {
    if (!isset($_POST["submit"]))
    {
    $id = $_GET["id"];
    $sql = "SELECT * FROM news WHERE id=$id";
    $result = mysql_query($sql);
    $myrow = mysql_fetch_array($result);
    ?>

    <form action="edit.php" method="post">
    <input type=hidden name="id" value="<?php echo $myrow["id"] ?>">

    Title:<INPUT TYPE="TEXT" NAME="title" VALUE="<?php echo $myrow["title"] ?>" SIZE=30><br>
    Message:<TEXTAREA NAME="post" ROWS=10 COLS=30><? echo $myrow["post"] ?></TEXTAREA><br>
    Who:<INPUT TYPE="TEXT" NAME="user" VALUE="<?php echo $myrow["user"] ?>" SIZE=30><br>

    <input type="hidden" name="cmd" value="edit">
    <input type='hidden' name='id' value='".$id."' />
    <input type="submit" name="submit" value="submit">

    </form>

    <? } ?>


    <?
    if ($_POST["submit"])
    {
    $title = $_POST["title"];
    $post = $_POST["post"];
    $user = $_POST["user"];
    $id = $_POST["id"];

    $sql = "UPDATE news SET title='$title',post='$post',user='$user' WHERE id='$id'";

    print $sql;
    die();


    //replace news with your table name above
    $result = mysql_query($sql);

    echo "Thank you! Information updated.";
    }
    }
    ?>[/quote]
  3. ugh this is frusterating me. A question I have is in php myadmin its said as ID not id... is all this case sensitive? Do you see something wrong I did. Thanks very much for your help so far.

    [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
    <?

    include("config.php");


    //If cmd has not been initialized
    if(!isset($cmd))
    {
    //display all the news
    $result = mysql_query("select id, title from news order by id");

    //run the while loop that grabs all the news scripts
    while($r=mysql_fetch_array($result))
    {
    //grab the title and the ID of the news
    $id=$r["id"];//take out the id
    $title=$r["title"];//take out the title

    //make the title a link
    echo "<a href='edit.php?cmd=edit&id=$id'>$title - Edit</a>";
    echo "<br>";
    }
    }
    ?>
    <?
    if($_GET["cmd"]=="edit" || $_POST["cmd"]=="edit")
    {
    if (!isset($_POST["submit"]))
    {
    $id = $_GET["id"];
    $sql = "SELECT * FROM news WHERE id=$id";
    $result = mysql_query($sql);
    $myrow = mysql_fetch_array($result);
    ?>

    <form action="edit.php" method="post">
    <input type=hidden name="id" value="<?php echo $myrow["id"] ?>">

    Title:<INPUT TYPE="TEXT" NAME="title" VALUE="<?php echo $myrow["title"] ?>" SIZE=30><br>
    Message:<TEXTAREA NAME="post" ROWS=10 COLS=30><? echo $myrow["post"] ?></TEXTAREA><br>
    Who:<INPUT TYPE="TEXT" NAME="user" VALUE="<?php echo $myrow["user"] ?>" SIZE=30><br>

    <input type="hidden" name="cmd" value="edit">
    <input type='hidden' value='".$id."' />
    <input type="submit" name="submit" value="submit">

    </form>

    <? } ?>


    <?
    if ($_POST["submit"])
    {
    $title = $_POST["title"];
    $post = $_POST["post"];
    $user = $_POST["user"];
    $id = $_POST["id"];

    $sql = "UPDATE news SET title='$title',post='$post',user='$user' WHERE ID='$id'";

    print $sql;
    die();


    //replace news with your table name above
    $result = mysql_query($sql);

    echo "Thank you! Information updated.";
    }
    }
    ?>
    [/quote]
  4. I do believe you are right.. Heres what I got:

    [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]UPDATE news SET title='SST Website',post='Hello and Welcome to the SST-',user='Guteman' WHERE id=''[/quote]

    How do I go about defining the id variable?
  5. [!--quoteo(post=353050:date=Mar 8 2006, 04:57 PM:name=lessthanthree)--][div class=\'quotetop\']QUOTE(lessthanthree @ Mar 8 2006, 04:57 PM) [snapback]353050[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    if ($_POST["$submit"])

    should be if ($_POST["submit"])

    for good measure, i'd do: if (isset($_POST["submit"]))

    Just to add, you having some security flaws in there that open your site up to sql injection. You should clean the values to make them as injection proof as possible.

    look at using functions like addslashes() to protect your site from malicious attacks.
    [/quote]

    This did not fix it :(
  6. Okay so now I got all the fields to show up correctly, now when I click submit to change a news post, nothing changes in the news! Ima need someones help again.




    Here is the code again.

    [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<?

    include("config.php");


    //If cmd has not been initialized
    if(!isset($cmd))
    {
    //display all the news
    $result = mysql_query("select id, title from news order by id");

    //run the while loop that grabs all the news scripts
    while($r=mysql_fetch_array($result))
    {
    //grab the title and the ID of the news
    $id=$r["id"];//take out the id
    $title=$r["title"];//take out the title

    //make the title a link
    echo "<a href='edit.php?cmd=edit&id=$id'>$title - Edit</a>";
    echo "<br>";
    }
    }
    ?>
    <?
    if($_GET["cmd"]=="edit" || $_POST["cmd"]=="edit")
    {
    if (!isset($_POST["submit"]))
    {
    $id = $_GET["id"];
    $sql = "SELECT * FROM news WHERE id=$id";
    $result = mysql_query($sql);
    $myrow = mysql_fetch_array($result);
    ?>

    <form action="edit.php" method="post">
    <input type=hidden name="id" value="<?php echo $myrow["id"] ?>">

    Title:<INPUT TYPE="TEXT" NAME="title" VALUE="<?php echo $myrow["title"] ?>" SIZE=30><br>
    Message:<TEXTAREA NAME="post" ROWS=10 COLS=30><? echo $myrow["post"] ?></TEXTAREA><br>
    Who:<INPUT TYPE="TEXT" NAME="user" VALUE="<?php echo $myrow["user"] ?>" SIZE=30><br>

    <input type="hidden" name="cmd" value="edit">

    <input type="submit" name="submit" value="submit">

    </form>

    <? } ?>
    <?
    if ($_POST["$submit"])
    {
    $title = $_POST["title"];
    $post = $_POST["post"];
    $user = $_POST["user"];

    $sql = "UPDATE news SET title='$title',post='$post',user='$user' WHERE id='$id'";
    //replace news with your table name above
    $result = mysql_query($sql);
    echo "Thank you! Information updated.";
    }
    }
    ?>[/quote]
  7. Alright guys, here is my issue. I cannot get [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<a href='edit.php?cmd=edit&id=$id'>[/quote] to work properly. Specificly the $id part. Its not seeing the id in the news through the sql. I know the rest of this works because I can enter an id number after the link and it works. So its gotta be that variable. Can you please help me out?


    [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<?

    include("config.php");


    //If cmd has not been initialized
    if(!isset($cmd))
    {
    //display all the news
    $result = mysql_query("select * from news order by id");

    //run the while loop that grabs all the news scripts
    while($r=mysql_fetch_array($result))
    {
    //grab the title and the ID of the news
    $title=$r["title"];//take out the title
    $id=$r["id"];//take out the id

    //make the title a link
    echo "<a href='edit.php?cmd=edit&id=$id'>$title - Edit</a>";
    echo "<br>";
    }
    }
    ?>
    <?
    if($_GET["cmd"]=="edit" || $_POST["cmd"]=="edit")
    {
    if (!isset($_POST["submit"]))
    {
    $id = $_GET["id"];
    $sql = "SELECT * FROM news WHERE id=$id";
    $result = mysql_query($sql);
    $myrow = mysql_fetch_array($result);
    ?>

    <form action="edit.php" method="post">
    <input type=hidden name="id" value="<?php echo $myrow["id"] ?>">

    Title:<INPUT TYPE="TEXT" NAME="title" VALUE="<?php echo $myrow["title"] ?>" SIZE=30><br>
    Message:<TEXTAREA NAME="message" ROWS=10 COLS=30><? echo $myrow["message"] ?></TEXTAREA><br>
    Who:<INPUT TYPE="TEXT" NAME="who" VALUE="<?php echo $myrow["who"] ?>" SIZE=30><br>

    <input type="hidden" name="cmd" value="edit">

    <input type="submit" name="submit" value="submit">

    </form>

    <? } ?>
    <?
    if ($_POST["$submit"])
    {
    $title = $_POST["title"];
    $message = $_POST["message"];
    $who = $_POST["who"];

    $sql = "UPDATE news SET title='$title',message='$message',who='$who' WHERE id=$id";
    //replace news with your table name above
    $result = mysql_query($sql);
    echo "Thank you! Information updated.";
    }
    }
    ?>[/quote]
  8. Alright guys, here is my issue. I cannot get [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<a href='edit.php?cmd=edit&id=$id'>[/quote] to work properly. Specificly the $id part. Its not seeing the id in the news through the sql. I know the rest of this works because I can enter an id number after the link and it works. So its gotta be that variable. Can you please help me out?


    [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<?

    include("config.php");


    //If cmd has not been initialized
    if(!isset($cmd))
    {
    //display all the news
    $result = mysql_query("select * from news order by id");

    //run the while loop that grabs all the news scripts
    while($r=mysql_fetch_array($result))
    {
    //grab the title and the ID of the news
    $title=$r["title"];//take out the title
    $id=$r["id"];//take out the id

    //make the title a link
    echo "<a href='edit.php?cmd=edit&id=$id'>$title - Edit</a>";
    echo "<br>";
    }
    }
    ?>
    <?
    if($_GET["cmd"]=="edit" || $_POST["cmd"]=="edit")
    {
    if (!isset($_POST["submit"]))
    {
    $id = $_GET["id"];
    $sql = "SELECT * FROM news WHERE id=$id";
    $result = mysql_query($sql);
    $myrow = mysql_fetch_array($result);
    ?>

    <form action="edit.php" method="post">
    <input type=hidden name="id" value="<?php echo $myrow["id"] ?>">

    Title:<INPUT TYPE="TEXT" NAME="title" VALUE="<?php echo $myrow["title"] ?>" SIZE=30><br>
    Message:<TEXTAREA NAME="message" ROWS=10 COLS=30><? echo $myrow["message"] ?></TEXTAREA><br>
    Who:<INPUT TYPE="TEXT" NAME="who" VALUE="<?php echo $myrow["who"] ?>" SIZE=30><br>

    <input type="hidden" name="cmd" value="edit">

    <input type="submit" name="submit" value="submit">

    </form>

    <? } ?>
    <?
    if ($_POST["$submit"])
    {
    $title = $_POST["title"];
    $message = $_POST["message"];
    $who = $_POST["who"];

    $sql = "UPDATE news SET title='$title',message='$message',who='$who' WHERE id=$id";
    //replace news with your table name above
    $result = mysql_query($sql);
    echo "Thank you! Information updated.";
    }
    }
    ?>[/quote]
×
×
  • 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.