Jump to content

Recommended Posts

Hi,

 

First off, heres my code:




<?php
//Start session
session_start();

//Include database connection details
require_once('emailconfig.php');

//Array to store validation errors
$errmsg_arr = array();

//Validation error flag
$errflag = false;

//Connect to mysql server
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
	die('Failed to connect to server: ' . mysql_error());
}

//Select database
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
	die("Unable to select database");
}

//Function to sanitize values received from the form. Prevents SQL injection
function clean($str) {
	$str = @trim($str);
	if(get_magic_quotes_gpc()) {
		$str = stripslashes($str);
	}
	return mysql_real_escape_string($str);
}

//Sanitize the POST values
$email_from = clean($_POST['toname']);
$email_subject = clean($_POST['subject']);
$email_body = clean($_POST['main_email']);



//If there are input validations, redirect back to the registration form
if($errflag) {
	$_SESSION['ERRMSG_ARR'] = $errmsg_arr;
	session_write_close();
	header("location: standard_make_email_failed.php");
	exit();
}

//Create INSERT query
$qry = ("UPDATE emails SET e_read='NO' WHERE e_read='YES' and e_body = '$main_subject'");
$result = @mysql_query($qry);

//Check whether the query was successful or not
if($result) {
	header("location: standard_make_email_posted.php");
	exit();
}else {
	die("Query failed");
}
?>

 

the values are taken from a submit form on the previous page. now my question is regarding

 

$qry = ("UPDATE emails SET e_read='NO' WHERE e_read='YES' and e_body = '$main_subject'");

 

i want to search my column for the $main_subject' value (which is a label in the form on previous page, that gets data from the table). the code directs me to the location: standard_make_email_posted.php page so i know the code works, but the value in the table doesnt amend from NO to YES, is there any obvious mistakes in my code?

 

thanks for reading, all comments welcomed

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.