Jump to content

Recommended Posts

Hi I have a table containg name, description, url which contains many records

 

When I submit a new form, I want it to check the url fields in the table and check it against what I have posted. Therefore something like

 

$check_table = function here to get all urls

 

if($_POST['url'] == $check_table) {

return false;

} else {

return true

}

 

However, how do I get all the urls and get it to check each one?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/52782-checking-_post-against-records-in-table/
Share on other sites

Thanks for your help and tip but whats that?

 

These are my functions now

 

function validateAdd($from=NULL){
	$valid = true;
	if(!$_POST[name]){$_POST[errors][name] = "<li>Please enter a headline for the campaign</li><br>"; $valid = false;}
	if(!$_POST[content]){$_POST[errors][content] = "<li>Please enter some content for the campaign</li><br>"; $valid = false;}
	if(!$_POST[url]){$_POST[errors][no_url] = "<li>Please enter a URL for the campaign</li><br>"; $valid = false;}
	if($_POST[discount_level_id] == 0){
		$_POST[errors][discount_level_id] = "<li>Please enter a discount level</li><br>"; $valid = false;
	}
	if(!$_POST[code]){$_POST[errors][code] = "<li>Please enter a HEX code for the campaign</li><br>"; $valid = false;}
	if($_POST[url] != ''){
	$get_url = $this->getUrl($_POST[url]);
	if($get_url > 0){

	$_POST[errors][url] = "<li>This URL has already been taken. Please choose another.</li><br>"; $valid = false;
	}
	}
	return $valid;
}

function getUrl($iUrlId)
{
	$db = new RCDB;
	$query  = "SELECT COUNT(url) 
			 AS num 
			 FROM campaign 
			 WHERE url = '$_POST[url]' ";
	$db->query($query);
	$db->next_record();
	return $this->listSize = $db->get_field('num');
}

[/code][/code]

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.