Jump to content

This did work, now it doesn't


Chubichan

Recommended Posts

My CMS pulls from the database just perfectly fine. My website pulls just perfectly fine. However, my put.php file will not insert into the database. Everything showing up on the website was manually inserted by me in phpmyadmin. I know this code probably isn't the best, but if someone could please help a complete newbie I would appreciate it. This code used to work, now the put.php form handler file will not update and I don't ever remember touching it. It is something to do with either the cms or the put file. Take a look...I know the code isn't the best...

 

<?php

Content Management php file
session_start();
if(!session_is_registered(myusername)) {
header("location:login.php");
}

include 'config.php';
include 'opendb.php';

$query = mysql_query("SELECT * FROM cms");
while($row = mysql_fetch_array($query))
{
$home = $row[('home')];

$field01 = $row[('field01')];
$field02 = $row[('field02')];
$field03 = $row[('field03')];
$field04 = $row[('field04')];
$field05 = $row[('field05')];

$mot = $row[('team')];
$sta = $row[('sta')];
$pf = $row[('form')];
$add = $row[('additionalforms')];
$fi = $row[('financial')];
$loc = $row[('location')];
$con = $row[('contact')];
$ms = $row[('mission')];
$about = $row[('aboutus')];
$dis = $row[('disclaimer')];
$addr = $row[('address')];
$addr02 = $row[('address02')];
}

$query = mysql_query("SELECT * FROM employees");
while($row = mysql_fetch_array($query))
{
$sta01 = $row[('sta01')];
$sta02 = $row[('sta02')];
$sta03 = $row[('sta03')];
$sta04 = $row[('sta04')];
$sta05 = $row[('sta05')];
$sta06 = $row[('sta06')];

$title01 = $row[('title01')];
$title02 = $row[('title02')];
$title03 = $row[('title03')];
$title04 = $row[('title04')];
$title05 = $row[('title05')];
$title06 = $row[('title06')];
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Dr. Michael D. Doyle | Payment Information</title>

<LINK REL=StyleSheet HREF="content_management.css" TYPE="text/css" />
<script defer type="text/javascript" src="pngfix.js"></script>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>

<script>var browser		= navigator.appName
var ver			= navigator.appVersion
var thestart	= parseFloat(ver.indexOf("MSIE"))+1 //This finds the start of the MS version string.
var brow_ver	= parseFloat(ver.substring(thestart+4,thestart+7)) //This cuts out the bit of string we need.

if ((browser=="Microsoft Internet Explorer") && (brow_ver < ) //By default the min. IE ver is set to 6. Change as desired.
{
window.location="http://www.drmdoyle.com/out_of_date.php"; //URL to redirect to.
}
//-->

</script>

</head>

<body>
<div id="container">

    <h3>Michael D. Doyle Content Management System</h3>
    
    <h3>Temporary Maintenance. For updates, please contact admin.</h3>
    	      
        <div id="form_wrapper">         
            <form method="post" action="put.php">
            <div><label for="field01">Top Link One</label><input type="text" name="field01" value="<?php echo $field01 ?>"/></div>
            <div><label for="field02">Top Link Two</label><input type="text" name="field02" value="<?php echo $field02 ?>"/></div>
            <div><label for="field03">Top Link Three</label><input type="text" name="field03" value="<?php echo $field03 ?>"/></div>
            <div><label for="field04">Top Link Four</label><input type="text" name="field04" value="<?php echo $field04 ?>"/></div>
            <div><label for="field05">Top Link Five</label><input type="text" name="field05" value="<?php echo $field05 ?>"/></div>
            
            <p>Enter your staff members and their job titles here</p>
            
            <div><label for="sta01">Staff 01</label><input type="text" name="sta01" value="<?php echo $sta01 ?>" maxlength="50"/></div>
            <div><label for="title01">Job Title</label><input type="text" name="title01" value="<?php echo $title01 ?>" maxlength="50"/></div>
            <div><label for="sta02">Staff 02</label><input type="text" name="sta02" value="<?php echo $sta02 ?>" maxlength="50"/></div>
            <div><label for="title02">Job Title</label><input type="text" name="title02" value="<?php echo $title02 ?>" maxlength="50"/></div>
            <div><label for="sta03">Staff 03</label><input type="text" name="sta03" value="<?php echo $sta03 ?>" maxlength="50"/></div>
            <div><label for="title03">Job Title</label><input type="text" name="title03" value="<?php echo $title03 ?>" maxlength="50"/></div>
            <div><label for="sta04">Staff 04</label><input type="text" name="sta04" value="<?php echo $sta04 ?>" maxlength="50"/></div>
            <div><label for="title04">Job Title</label><input type="text" name="title04" value="<?php echo $title04 ?>"maxlength="50"/></div>
            <div><label for="sta05">Staff 05</label><input type="text" name="sta05" value="<?php echo $sta05 ?>" maxlength="50"/></div>
            <div><label for="title05">Job Title</label><input type="text" name="title05" value="<?php echo $title05 ?>" maxlength="50"/></div>
            <div><label for="sta06">Staff 06</label><input type="text" name="sta06" value="<?php echo $sta06 ?>" maxlength="50"/></div>
            <div><label for="title06">Job Title</label><input type="text" name="title06" value="<?php echo $title06 ?>" maxlength="50"/></div>
           
            <p>To add paragraphs for any text below this line, press RETURN.</p>     
            <div><label for="index">Homepage</label><textarea name="home" rows="15" cols="50" ><?php echo $home ?> </textarea></div>
            <div><label for="mot"><?php echo $field01 ?></label><textarea name="mot" rows="15" cols="50" ><?php echo $mot ?> </textarea></div>
            <div><label for="sta">Staff</label><textarea name="sta" rows="15" cols="50" ><?php echo $sta ?> </textarea></div>
            <div><label for="pf"><?php echo $field02 ?></label><textarea name="pf" rows="15" cols="50" ><?php echo $pf ?> </textarea></div>
            <div><label for="add">Additional Forms</label><textarea name="add" rows="15" cols="50" ><?php echo $add ?> </textarea></div>
            <div><label for="fi"><?php echo $field03 ?></label><textarea name="fi" rows="15" cols="50" ><?php echo $fi ?> </textarea></div>
            <div><label for="loc"><?php echo $field04 ?></label><textarea name="loc" rows="15" cols="50" ><?php echo $loc ?> </textarea></div>
            <div><label for="con"><?php echo $field05 ?></label><textarea name="con" rows="15" cols="50"><?php echo $con ?> </textarea></div>
            <div><label for="ms">Mission Statement</label><textarea name="ms" rows="15" cols="50" ><?php echo $ms ?> </textarea></div>
            <div><label for="about">About our Practice</label><textarea name="about" rows="15" cols="50" ><?php echo $about ?> </textarea></div>
            <div><label for="dis">Disclaimer</label><textarea name="dis" rows="15" cols="50" ><?php echo $dis ?> </textarea></div>            
            <p>Input addresses here. This information is pulled to everywhere the address appears on the site.</p>
            <div><label for="address">Address</label><textarea name="address" rows="15" cols="50" ><?php echo $addr ?> </textarea></div>
            
            <p>Input second address here.</p>
            <div><label for="address02">Address 2</label><textarea name="address02" rows="15" cols="50" ><?php echo $addr02 ?> </textarea></div>
            
            <p>Would you like to add a new user?
            <div><label for="newuser">New Username</label><input type="text" name="newuser" /></div>
            <div><label for="newpass">New Password</label><input type="text" name="newpass" /></div>  
               
            <div class="actions"><input type="submit" name="submit" value="Submit Content" class="submit"/></div>
            </form>
            
            <p>
            <a href="logout.php">Log Out</a></p>
        </div>
</div>
</body>
</html>

 

put.php form handler file

<?php
    if(isset($_POST['submit']))
    {
    include 'config.php';
    include 'opendb.php';

$home = $_POST['home'];

$field01 = $_POST['field01'];
$field02 = $_POST['field02'];
$field03 = $_POST['field03'];
$field04 = $_POST['field04'];
$field05 = $_POST['field05'];
    
$mot = $_POST['mot'];
$sta = $_POST['sta'];
$pf = $_POST['pf'];
$add = $_POST['add'];
$fi = $_POST['fi'];
$loc = $_POST['loc'];
$con = $_POST['con'];
$ms = $_POST['ms'];
$about = $_POST['about'];
$dis = $_POST['dis'];
$addr = $_POST['address'];
$addr02 = $_POST['address02'];

$sta01 = $_POST['sta01'];
$sta02 = $_POST['sta02'];
$sta03 = $_POST['sta03'];
$sta04 = $_POST['sta04'];
$sta05 = $_POST['sta05'];
$sta06 = $_POST['sta06'];

$title01 = $_POST['title01'];
$title02 = $_POST['title02'];
$title03 = $_POST['title03'];
$title04 = $_POST['title04'];
$title05 = $_POST['title05'];
$title06 = $_POST['title06'];

$newuser = $_POST['newuser'];
$newpass = $_POST['newpass'];
                                      
    $query = "INSERT INTO cms (home, field01, field02, field03, field04, field05, team, sta, form, additionalforms, financial, location, contact, mission, aboutus, disclaimer, address, address02)
					VALUES ('$home', '$field01', '$field02', '$field03', '$field04', '$field05', '$mot', '$sta', '$pf', '$add', '$fi', '$loc', '$con', '$ms', '$about', '$dis', '$addr', '$addr02')";

$query = "INSERT INTO employees (sta01, sta02, sta03, sta04, sta05, sta06, title01, title02, title03, title04, title05, title06)
					VALUES ('$sta01', '$sta02', '$sta03', '$sta04', '$sta05', '$sta06', '$title01', '$title02', '$title03', '$title04', '$title05', '$title06')";

$query = "INSERT INTO members (username, password) VALUES ('$newuser', '$newpass')";
    mysql_query($query) or die('An error has occured.: ' . mysql_error());
        
    include 'closedb.php';
    echo "You have successfully updated your web content. Check";
}
?>
<a href="http://www.drmdoyle.com">your site</a> now, or <a href="http://www.drmdoyle.com/content_management.php">edit more stuff</a>.
   	
   	

Link to comment
Share on other sites

Coding looks fine to me, if I haven't missed anything. Are you sure all the tables are in your put.php file? Is there any that you have extra tables in your mysql database?

 

Yep everything is in there table wise. I am at a loss. Had a guy at work take a look and he is mainly cold fusion so he couldn't really tell me anything, just how he would do it in CF. Also, I know that I should not be using a while loop. For some reason that is all that I can find as examples. Maybe that is where my problem lies. I dunno.

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.