help

Hi everyone please help me in this one, im new in php and couldnt fix this problem, please see my code.

<?php if (intval($_GET['inv']) == 0) { redirect_to('content.php'); } if (isset($_POST['submit'])) { $errors = array(); } ?>

i want to post the data in the same form, but ive been redirected to content.php because of this code (intval($_GET[‘inv’]) == 0) I wondering i cannot pass that validation while im just catching the $_GET[‘inv’]

guys please help.

From your code it is not clear, where is this array defined and populated: $sel_inventory ?
Also if you have a form with method POST, I would suggest to use this code:
[php]
[/php]

and also change $_GET[‘inv’] to $_POST[‘inv’] in your php code.

Hi Sir I will post all the codes so u can undestand it clearly, my goal here is after clicking the submit button is the same page will load with the updated data on it.

<?php require_once("includes/connection.php"); ?> <?php require_once("includes/functions.php"); ?> <?php find_item(); ?> <?php /*if (intval($_GET['inv']) == 0) { redirect_to('content.php'); }*/ if (isset($_POST['submit'])) { $errors = array(); // Form Validation $required_fields = array('item', 'position'); foreach($required_fields as $fieldname) { if (!isset($_POST[$fieldname]) || empty($_POST[$fieldname])) { $errors[] = $fieldname; } } $fields_with_lengths = array('item' => 30); foreach($fields_with_lengths as $fieldname => $maxlength ) { if (strlen(trim(mysql_prep($_POST[$fieldname]))) > $maxlength) { $errors[] = $fieldname; } } if (empty($errors)) { // Perform Update //$id = mysql_prep($_GET['inv']); $item = mysql_prep($_POST['item']); $position = mysql_prep($_POST['position']); /*$query = "UPDATE inventory SET item = '{$item}', position = {$position} WHERE id = {$id}"; $result = mysql_query($query, $connection); if (mysql_affected_rows() == 1) { // Success } else { // Failed } } else { // Errors occurred*/ } }// end: if (isset($_POST['submit'])) ?> <?php include("includes/header.php"); ?>

SELECT ITEM:

<?php echo navigation($sel_inventory); ?>

Edit Item: <?php echo $sel_inventory['item']; ?>

Item name:

Position: <?php $inventory_set = get_inventory(); $inventory_count = mysql_num_rows($inventory_set); // $subject_count + 1 b/c we are adding a subject for($count=1; $count <= $inventory_count+1; $count++){ echo "{$count}"; } ?>

			&nbsp;&nbsp;
			<a href="delete_subject.php?subj=<?php echo urlencode($sel_inventory['id']); ?>" 
			onclick="return confirm('Are you sure?');">Delete Subject</a>
		</form>
	<br />
	<a href="content.php"> Cancel </a>
	</td>
</tr>
<?php include("includes/footer.php"); ?>

hello phpadmin,

i already solve this problem, its i mistake that beginners like me commit. anyway thank you for you help.

Sponsor our Newsletter | Privacy Policy | Terms of Service