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 [email protected] 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

Link to comment
https://forums.phpfreaks.com/topic/278682-ecommerce-site-edit-page/
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>

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.