Jump to content

Recommended Posts

Hello all, I need a little help if someone has some extra time.

 

I have created a script that checks for a line of code on an external url and if it's on the page give a success message and if not found give error alert...

 

The issue I'm having is if the person have more than one site they want to verify and they have already verified the code on one... when they go to verify the other sites it updates automatic because it was found on the first one.

 

because I use $row and it can contain more than one url

 

I assume my script is only checking the 1st url on the list and not the others...

 

anyone have any ideas???

 

Thanks in advance!!!

 

 

session_start(); 
include("config.php");

$sql_site = ("SELECT * FROM table WHERE `email` = '$_SESSION[email]' ");
$site_con = mysql_query($sql_site, $conn) or die(mysql_error());
$numrows = mysql_num_rows($site_con);

if($numrows > 0){
while($row = mysql_fetch_array($site_con))
{
 $sql_cat = "SELECT Cate_Details FROM `category` WHERE idCategory = '". $row["idCategory"]."'";
	   $rec_cat = mysql_query($sql_cat) or die(mysql_error());
	   $rs_cat = mysql_fetch_array($rec_cat);
	   $sql_stat = "SELECT staDetails FROM `site_status` WHERE idStatus = '". $row["idStatus"]."'";
	   $rec_stat = mysql_query($sql_stat) or die(mysql_error());
	   $rs_stat = mysql_fetch_array($rec_stat);
$row[url] = $row[url]++;
$partnersURL="$row[url]";
$htmlString=file_get_contents($partnersURL);

if (eregi('46546546546', $htmlString)) {

$ver_update=("UPDATE `table` SET `id_verification` = '2' WHERE `email` = '".$_SESSION[email]."'") or die(mysql_error());
if (!mysql_query($ver_update,$conn))
  {
  die('Error: ' . mysql_error());
  }
echo '<script language=javascript>';
echo 'alert("Validation code was found! \n Your site has been successfully verified.");'; 
echo '</script>';
echo '<SCRIPT language="JavaScript">
<!--
window.location="my_account.php";
//-->
</SCRIPT>
';
}else{
echo '<script language=javascript>';
echo 'alert("Validation code was not found! \n Please make sure you have entered the correct \n validation code and that its on the index page of your site.");';
echo '</script>';
echo '<SCRIPT language="JavaScript">
<!--
window.location="my_account.php";
//-->
</SCRIPT>
';
}
}
}else{
echo"User not logged.";
}

Link to comment
https://forums.phpfreaks.com/topic/172913-solved-php-help/
Share on other sites

Ok I have figured out that the script is cycling through the urls fine but updating all sites

to verified and not just the one site that is actually has been verified.

 

I assume that it's in the following code but not sure how else I could write it cause

the matching rows in this and the user table are email so that is the only way I can think of to do it. 

 

$ver_update=("UPDATE `table` SET `id_verification` = '2' WHERE `email` = '".$_SESSION[email]."'") or die(mysql_error());

 

This is the full script... it works fine but validates all url when it should only update the ones that contain the validation code.

 

 

<?php
session_start(); 
include("config.php");

$sql_site = ("SELECT * FROM sit_details_tmp WHERE `email` = '$_SESSION[email]' ");
$site_con = mysql_query($sql_site, $conn) or die(mysql_error());
$numrows = mysql_num_rows($site_con);

if($numrows > 0){
while($row = mysql_fetch_array($site_con))
{


$partnersURL="$row[url]";
$htmlString=file_get_contents($partnersURL);
$var_code = "$row[ver_code]";

if (eregi($var_code, $htmlString)) {

$ver_update=("UPDATE `sit_details_tmp` SET `id_verification` = '2' WHERE `email` = '".$_SESSION[email]."'") or die(mysql_error());
if (!mysql_query($ver_update,$conn))
  {
  die('Error: ' . mysql_error());
  }

echo '<script language=javascript>';
echo 'alert("Validation code was found! \n Your site has been successfully verified.");'; 
echo '</script>';
echo '<SCRIPT language="JavaScript">
<!--
window.location="my_account.php";
//-->
</SCRIPT>
';
}else{
echo"$var_code";
echo '<script language=javascript>';
echo 'alert("Validation code was not found! \n Please make sure you have entered the correct \n validation code and that its on the index page of your site.");';
echo '</script>';
echo '<SCRIPT language="JavaScript">
<!--
window.location="my_account.php";
//-->
</SCRIPT>
';
}
}
}else{
echo"User not logged.";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/172913-solved-php-help/#findComment-911988
Share on other sites

does that table not have a primary key? just use the primary key when updating. IE

 

if (eregi($var_code, $htmlString)) {

$ver_update=("UPDATE `sit_details_tmp` SET `id_verification` = '2' WHERE `id` = '".row['id']."'") or die(mysql_error());
if (!mysql_query($ver_update,$conn))
  {
  die('Error: ' . mysql_error());
  }

 

by the way you need to encase associative array keys with single quotes

 

$array[key];//wrong
$array['key'];//right

Link to comment
https://forums.phpfreaks.com/topic/172913-solved-php-help/#findComment-911995
Share on other sites

I do have a primary key but in table one it's site_id and in the user table it's id_user

and the id fields don't match so I'm not sure I follow on how to do what your saying.

 

I used

WHERE `email` = '$_SESSION[email]'

cause when the user registers I register the session value email and that way I know the information I'm pulling belongs to the right user.

 

The only matching fields I have between the two table is email

 

 

Link to comment
https://forums.phpfreaks.com/topic/172913-solved-php-help/#findComment-912017
Share on other sites

does that table not have a primary key? just use the primary key when updating. IE

 

if (eregi($var_code, $htmlString)) {

$ver_update=("UPDATE `sit_details_tmp` SET `id_verification` = '2' WHERE `id` = '".row['id']."'") or die(mysql_error());
if (!mysql_query($ver_update,$conn))
  {
  die('Error: ' . mysql_error());
  }

 

by the way you need to encase associative array keys with single quotes

 

$array[key];//wrong
$array['key'];//right

 

Ok I have figured out that the script is cycling through the urls fine but updating all sites

to verified and not just the one site that is actually has been verified.

 

*** not all sites in table but all site for that user***

 

I want it to work so that it checks all the users urls one by one and updates one by one

 

now with

ver_update=("UPDATE `sit_details_tmp` SET `id_verification` = '2' WHERE `id` = '".row['id']."'") or die(mysql_error());

it's updating all listings that the user has at once and not only the one that have the verification code.

 

If you understand already... sorry. I just assume you figured the issues was updating all urls in the table and not just the users ones.

 

Anyways, if you have any ideas it sure would help.

 

Thanks!!

Link to comment
https://forums.phpfreaks.com/topic/172913-solved-php-help/#findComment-912024
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.