Jump to content


Photo

back to basics


  • Please log in to reply
2 replies to this topic

#1 spires

spires
  • Members
  • PipPipPip
  • Advanced Member
  • 492 posts

Posted 15 September 2006 - 06:39 PM

Hi,

I am trying to pass a ID value through a form.
I'm getting the id value into a function, the function holds the form.
I then want the form to read the id value then $_POST it into a variable,
which is then stored into a database.

I've done this sooo many times before but its not working.

Could someone take a quick look.
I know the answer is right under my nose.

Thanks
<?php
session_start();

function add_comments($view_id) {
$user_profile = $_SESSION['username'];
$id = $view_id;

$comError = array();

if (!empty($_POST['comssubmit'])) {
	if ($_POST['title']=='')
		$comError['title'] = 'Add title';
	if ($_POST['coms']=='')
		$comError['coms'] = 'Add Comments';
		
	if (count($comError) == 0) {
		
		$sql= mysql_query("SELECT * FROM user_info WHERE username='$user_profile'") or die ('could not connect'); 
		$row1 = mysql_fetch_array($sql);
		$id = $row1['id'];
		
		$title = addslashes($_POST['title']);
		$coms = addslashes($_POST['coms']);
		$date = date("Y-m-d");
		$contact_id = $_POST['id'];
		
		
		$link = '<a href="../edit.php" class="link">Return to profile</a>';
		
		$sql1= mysql_query("INSERT INTO comments (user_id, contact_id, title, coms, date) VALUES ('$id', '$contact_id', '$title', '$coms', '$date')");
			if ($sql1) {
			$ok = 'Your details have been updated,<br>'.$link.'';
		} else {
			$notOk = "Sorry, there was an Error";
		}
		
	} else {
	if (empty($title) || empty($coms)) {
	foreach ($comError as $error) {
	$strError .= '<div class="error">';
		$strError .= "<li>$error</li>";
	}
	$strError .= '</div>';
} 
		
}	
}

$coms_query = mysql_query("SELECT * FROM comments WHERE user_id='$id'") or die ('could not connect1');
$row = mysql_fetch_array($coms_query);

	echo '<BR>
	<form name="form2" method="post" action="'.$_SERVER['PHP_SELF'].'">
	<input type="hidden" name="id value="'.$row['id'].'">
	<TABLE width="667" border="0" cellspacing="0" cellpadding="0">
		<TR>
		<TD height="20" bgcolor="#0000FF" valign="bottom" colspan="2">
		<img src="JPGS/profile/comments.jpg" width="668" height="21">
		</TD>
		</TR>
		<TR>
		<TD class="TLRB_border" bgcolor="#EEEEEE" valign="top">
		<input type="text" name="title" id="title" value="'.$row['title'].'">
		</TD>
		<TD class="TLRB_border" bgcolor="#EEEEEE" valign="top" align="right">
		&nbsp;&nbsp;&nbsp;&nbsp;'.$row['date'].'<br>
		</TD>
		</TR>
		<TR>
		<TD class="TLRB_border" height="200" bgcolor="#EEEEEE" valign="top" colspan="2">
		<textarea name="coms" cols="80" rows="12" wrap="PHYSICAL" id="coms" value="'.$row['coms'].'">'.$row['coms'].'</textarea>
		</TD>
		</TR>
		<TR>
		<TD  colspan="2" align="right">
		 <input type="submit" name="comssubmit" value="Submit">
		</TD>
		</TR>
		</TABLE>';
		echo $strError;
		echo $ok;
		echo $notOk;
		echo '</form>'; 
}
?>

How to make over $600 a day from AdSense? Discover EXACTLY how he does it in these videos:
http://www.adsense-online.com

#2 Destruction

Destruction
  • Members
  • PipPipPip
  • Advanced Member
  • 108 posts

Posted 15 September 2006 - 07:12 PM

but its not working


It may help to know how it's "not working".  Is there a specific error message etc...if so, please post it.

Thanks,

Dest

#3 spires

spires
  • Members
  • PipPipPip
  • Advanced Member
  • 492 posts

Posted 15 September 2006 - 07:20 PM

NO, No error.

It uploads all of the fields into the database apart from into 'contact_id'.

This feild should get the id value which come into the function.
add_comments($view_id)

But i can seem to get it from there, into the INSERT query.

Any ideas
How to make over $600 a day from AdSense? Discover EXACTLY how he does it in these videos:
http://www.adsense-online.com




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users