Jump to content

ECommerce Site Edit Page


chibiwawa

Recommended Posts

I am having trouble getting my edit page for my ecommerce site to work.

You can log in here: http://lpehrson.mydevryportfolio.com/webdev/admin_login.php The user name is test@test.com and the password is test.

The edit page is here: here: http://lpehrson.mydevryportfolio.com/webdev/edit.php

As you can see there are a lot of errors. I can't find where I went wrong in the code.

I have attached the files to this post.

If you could help that would be great.

 

I got the following response on another form:

 

The errors are pretty straight forward. Your include paths are wrong which is why your getting those errors, and your database username is still using an @localhost, which wont work on a live site. You need to call the right include directory, probably /includes/file.php would do it. or ../includes, i dont know how you have the directories structured, but you can figure that part out. As for accessing the DB you'll need to get server username , password and probably the database name from your hosting provider, make those changes and you'll be on the right track.

 

I changed the includes and it did not fix it. How would I sign into the database? I am very new to PHP. Please help!

 

LPehrsoniLab4 (2).zip

Edited by chibiwawa
Link to comment
Share on other sites

I made the following changes:

 

<?php
            if(isset($_POST['Submit_Update']))
                {
                    include('includes/dbc_admin.php');
                    $table = $_POST['products'];
                    $id = $_POST['id'];
                    $title = $_POST['title'];
                    $description = $_POST['description'];
                    mysql_query("UPDATE $table SET title = '$title', message = '$message' where id = '$id'") or trigger_error('Error: '.mysql_error(), E_USER_ERROR);
                    $msg = "Your content has been successfully updated!<br />";
                }
        ?>

        <?php
            if(isset($msg))
                {
                    echo $msg;
                }
        ?>

                 <form method="post" action="<?php $_SERVER['PHP_SELF'];?>">
            <?PHP
                // Get the ID and Table name into variables
                $id = $_GET['id'];
                $table = $_GET['table'];

                include('includes/dbc_admin.php');
                $sql = "SELECT * FROM $table where id = $id";
                $result = mysql_query($sql);
                while($row = mysqli_fetch_assoc($result))
                    {
                        echo '<input type="hidden" name="id" value="'.$id.'">';
                        echo '<input type="hidden" name="table" value="'.$table.'">';
                        echo '<textarea name="message" width="500" height="300">'.$row['message'].'</textarea>';
                    }
            ?>
            <input type="submit" name="Submit_Update" value="Update">
        </form>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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