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