Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Update mysql with php form problem

$
0
0

Hello i am trying to make an admin-panel and right now im stuck at the part where you should edit the content/topic at the home page

 

so everything exept the submit button work please help!

 

here's the code

<?php 
	include 'core/init.php';
	protect_page();
	admin_protect();
	include 'includes/overall/overall_header.php';
	?>
	<title> Quadrox - AdminPanel </title>
	<article>	
		<?php include 'includes/adminaside.php'?>	
		<section>
			<h3>Admin - Panel</h3>
			<?php
				$hid = $_GET['hid'];
				$sql = "SELECT * FROM Home WHERE id = '".$hid."'";
				$result = mysql_query($sql);
				$row = mysql_fetch_array($result);
			?>
			<form method="post" action="ednew.php">
				<input type="hidden" name="id" value="<?php echo "$row[id]"?>">
			<table cellpadding="8">
				
				<tr>
					<td>Home-topic:</td>
					<td>
					<input type="text" name="Home_topic" size="50" value="<?php echo "$row[Home_topic]"?>">
					</td>
				</tr>
				<tr>
					<td>Home-content:</td>
					<td>
					<textarea name="Home_content" rows="7" cols="60"><?php echo "$row[Home_content]"?>
					</textarea>
					</td>
				</tr>
				<tr>
				<td></td>
					<td>
						<input type="submit" value="Update Home Page" name="Home_update">
					</td>
				</tr>
			</table>
			</form>
			<?php
			$Home_topic = $_POST['Home_topic'];
			$Home_content = $_POST['Home_content'];
			if (isset($_POST['Home_update'])){
			$sql = "UPDATE Home SET Home_topic='$Home_topic', Home_content='$Home_content' WHERE id='$hid'";
			mysql_query($sql);
			echo "Success";
		}
			?>
		</section>
	</article>

<?php include 'includes/overall/overall_footer.php'?>

Viewing all articles
Browse latest Browse all 13200

Trending Articles