Jump to content

Update mysql with php form problem


merlieon

Recommended Posts

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'?>
Link to comment
https://forums.phpfreaks.com/topic/281941-update-mysql-with-php-form-problem/
Share on other sites

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.