come collegare un id di mysql con un file specifico

romeocharly

Utente Attivo
11 Feb 2016
69
1
8
Come posso collegare un id che proviene da un db mysql con un download specifico?
Mi spiego se non avessi opzioni cioe un solo id saprei farlo usando un redirect ad un url.
Ma con 4 varialbili, cioe 4 id di mysql( che vanno dall'1 al 10 in numero ), come si deve procedere passo passo?
Il link alla pagina di scelta dell'id è il seguente:
http://www.ebookwebproject.com/viralrefer/verify.php?prizeid=7
Nel caso succitato l'id è il numero 7; ma da qui non so andare avanti.( a meno che avessi solo il numero id 7).

Grazie e buonanotte
 
Buongiorno,
grazie per la risposta;
Il software che ho acquistato è in modalità demo, che con l'iserimento di uno script dovrebbe trasformarsi in versione full: gia qui ho dei problemi.
In pratica usando il link che compare alla pagina:
http://www.ebookwebproject.com/viralrefer/index.php#containersocial
si ha un univoco : Your Referral Link: .... (diverso per ogni visitatore della pagina; gestito da id autoincrementante su mysql (mi pare funzioni quello)
Mettendo questo link sui social o nelle email e cliccandoci sopra alotre persone, dovrebbe darti dei punti (prize) che ti permettono di ottenere un bonus. In questo caso degli ebook, in download.
Per chiarezza meto la pagina index come codice:

Codice:
<?php
session_start();
require_once("inc/funcs.php");
$ip = $_SERVER['REMOTE_ADDR'];
if(get_user($ip) == false){
	add_user($db,$ip, $_GET['ref']);
	$_SESSION['ip'] = $ip;
}
$user = mysql_fetch_object(mysql_query("SELECT * FROM `$db`.`users` WHERE `ip`='". $ip ."'"));
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head><script>

$(document).ready(function(){		
				
	$().socialTrafficPop({
		timeout: 15,
		title: "Viral Refer 2.0 - Demo",
		message: 'Share our website with your friends using the buttons below!',
		google_url: "http://www.ebookwebproject.com/viralrefer/",
		fb_url: "http://www.ebookwebproject.com/viralrefer/",
		closeable: false,
		advancedClose: false,
		opacity: '0.45',
		twitter_method: "tweet",
		tweet_url: 'http://www.ebookwebproject.com/viralrefer/index.php?ref=1',
		tweet_text: 'Viral Refer 2.0 - Share your referral link with your friends and win amazing rewards!'
	});
	
});


</script>
	<meta charset="UTF-8">
	<title>Viral Refer 2.0 - Demo</title>
	<link rel="icon" type="image/x-icon" href="http://www.ebookwebproject.com/viralrefer/images/favicon.ico" />	
	<link rel="stylesheet" href="fonts/TitilliumText/stylesheet.css" />
	<meta name="Description" content="Share your Link with your friends and unlock your Gift" /> 
	<meta property=og:title content="Get a Free Gifts Now!" />
    <meta property=og:type content=website />
	<meta property=og:description content="Win free gifts now, try it now. Powered by ViralRefer.com" />
	<meta property=og:image content="http://i.imgur.com/rLBu0wP.png" />
	<link rel="stylesheet" href="css/style.css" />
     <meta name="keywords" content="survey, online, referral, rewards, win, prize, gift, card, games">
   
				        <link href="social-traffic-pop.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
<script src="http://platform.twitter.com/widgets.js" type="text/javascript"></script>
<script src="jquery.stp.min.js" type="text/javascript"></script>
<script type="text/javascript">var switchTo5x=true;</script>
<script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>
<script type="text/javascript">stLight.options({publisher: "6c98ad43-5976-445e-baf4-532cc9d13687", doNotHash: false, doNotCopy: false, hashAddressBar: false});</script>

<link type="text/css" href="foobar/jquery.foobar.2.1.css" rel="Stylesheet" />
  <style type="text/css">
    #social_target { margin-left:20px; }
    ul.socialbuttons { height: 32px; padding: 0 !important; margin:0 !important; }
    ul.socialbuttons li { padding:6px !important; float: left; list-style: none !important; }  
  </style>
  <script type="text/javascript" src="scripts/jquery-1.7.1.min.js"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
function copyToClipboard(element) {
  var $temp = $("<input>");
  $("body").append($temp);
  $temp.val($(element).text()).select();
  document.execCommand("copy");
  $temp.remove();
}
</script>
<script>
function myFunction() {
    alert("Your Referral Link was copied to clipboard!\n#Tip: Share your Refferal Link in your Facebook, Twitter.. To get EXTRA Points!!");
}
</script>
</head>
<body>

	<div class="right">
	<div class="menudrop">
	    <h3><a href="#"><img src="images/arrow.png" alt="menu"></a></h3>
	    <ul>
		 <li><a href="#containersocial">**FREE POINTS**</a></li>
	      <li><a href="privacy.php">Privacy Policy</a></li>
	      <li><a href="tos.php">Terms</a></li>
	    </ul>
	</div>
	</div>
			<center><h1 id="title"><a href="index.php"><span style="color:#069">«</span>Viral Refer 2.0<span style="color:#069">»</span></a><br />
			<span style="font-weight: 300; font-size: 14px; color: #27C1F4;">Share your Link and unlock your Rewards !</span></h1></center>			
	<br class="clear" />
	<div id="container">
	
			<div id="ref_container">
				<div style="float: left">
						<div class="dropbutton" style=" height: 40px;">
								<div class="black" style=" border-radius: 4px 0 0 4px;height: 32px;">
									<img style="margin-top: 1px;" src="http://i.imgur.com/dKP6K52.png" width="25px" height="25px" title="Your Points">
								</div>
								<div class="black" style=" height: 40px; border-radius: 0 4px 4px 0;">
									<a style="cursor: pointer; color: rgb(165, 204, 0);font-size: 23px!important;line-height: 42px!important;"><b><font size="6"><?php echo $user->referrals;?></font></b> Points</a>
									&nbsp;&nbsp;
									
								</div>
								<a href="javascript:history.go(0)"><img style="position: absolute; right: -30px;top: 10px;" src="http://i.imgur.com/e8L99Pn.png" width="25px" height="25px"></a>

						</div>
						
				</div>
				<p><font size="4">Your Referral Link:</font>  <input title="copy & paste" readonly="readonly" type="text" value="<?php echo $site_url; ?>?ref=<?php echo $user->id;?>" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#copy"><img style="position: absolute; right: 5px;top: 5px;" onclick="copyToClipboard('#p1'); myFunction();" src="http://i.imgur.com/krE6Lmt.gif"></a></p>
				<p style="display: none;" id="p1"><?php echo $site_url; ?>?ref=<?php echo $user->id;?></p>
				
				
			</div>
	</div>

	<div id="container">

				<h2>Welcome To Viral Refer 2.0 ** DEMO VERSION **</h2>				
				<p class="left_15">Share your unique <b>REFERRAL LINK</b> with your friends and you will receive <b>1 POINT FOR EACH VISITOR</b>. Yes, it's that simple!</br>
				<br>::::::<b>Get this Script here with <b><u>SPECIAL DISCOUNT<b></u>: <font size="5" color="#F5F507"><a href="http://viralrefer.com">VIRALREFER.COM</a></font>:::::</br>
	
			    
	</div>
	
	<div id="container">
		<div class="drop_top">
	<?php
		for($i = 1; $i <= 50; $i++){
			if((list($id,$thumb,$name,$desc,$prize,$cost) = get_prize($i)) == true){
				echo "<div class=\"grid_1\" id=\"drop-rewards\"><div class=\"reward_image\"><h5>$cost pts</h5><img src=\"$thumb\" width=\"180\" height=\"180\"></div><div class=\"reward_text\"><p style=\"float: left\">$name</p></div>";
				if($user->referrals >= $cost){
					echo '
						<div class="dropbutton">
								<div class="black">
									<img src="images/unlock.png">
								</div>
								<div class="black">
									<a style="color: #cf9" href="verify.php?prizeid=' . $id . '">Redeem</a>
								</div>
						</div>';
				}else{
					echo '
						<div class="dropbutton">
								<div class="black">
									<img src="images/lock.png" title="not enough points">
								</div>
								<div class="black">
									<a title="not enough points" style="cursor: pointer; color: #ff5555">Locked</a>
								</div>
						</div>';
				}
				echo '</div>';
			}
		}
	?>
		</div>
	<br class="clear" />
		
		
		
		
		
	</div>
	<div id="containersocial">
	<h2>#TIPS: GET FREE EXTRA POINTS</h2>
<center>EARN <u>EXTRA POINTS</u> BY SHARE ON SOCIAL NETWORKS, <b>1 POINT FOR EACH SHARE!</b> </br></br>
<span class='st_facebook_large' st_url='<?php echo $site_url; ?>?ref=<?php echo $user->id;?>' displayText='Facebook'></span>
<span class='st_twitter_large' st_url='<?php echo $site_url; ?>?ref=<?php echo $user->id;?>' displayText='Tweet'></span>
<span class='st_linkedin_large' st_url='<?php echo $site_url; ?>?ref=<?php echo $user->id;?>' displayText='LinkedIn'></span>
<span class='st_tumblr_large' st_url='<?php echo $site_url; ?>?ref=<?php echo $user->id;?>' displayText='Tumblr'></span>
<span class='st_reddit_large' st_url='<?php echo $site_url; ?>?ref=<?php echo $user->id;?>' displayText='Reddit'></span>
<span class='st_orkut_large' st_url='<?php echo $site_url; ?>?ref=<?php echo $user->id;?>' displayText='Orkut'></span>
<span class='st_netlog_large' st_url='<?php echo $site_url; ?>?ref=<?php echo $user->id;?>' displayText='Netlog'></span>
<span class='st_myspace_large' st_url='<?php echo $site_url; ?>?ref=<?php echo $user->id;?>' displayText='MySpace'></span>
<span class='st_livejournal_large' st_url='<?php echo $site_url; ?>?ref=<?php echo $user->id;?>' displayText='LiveJournal'></span>
<span class='st_instapaper_large' st_url='<?php echo $site_url; ?>?ref=<?php echo $user->id;?>' displayText='Instapaper'></span>
<span class='st_google_bmarks_large' st_url='<?php echo $site_url; ?>?ref=<?php echo $user->id;?>' displayText='Bookmarks'></span>
<span class='st_pinterest_large' st_url='<?php echo $site_url; ?>?ref=<?php echo $user->id;?>' displayText='Pinterest'></span>
<span class='st_google_large' st_url='<?php echo $site_url; ?>?ref=<?php echo $user->id;?>' displayText='Google'></span>
<span class='st_formspring_large' st_url='<?php echo $site_url; ?>?ref=<?php echo $user->id;?>' displayText='Formspring'></span>
<span class='st_email_large' st_url='<?php echo $site_url; ?>?ref=<?php echo $user->id;?>' displayText='Email'></span>
<span class='st_digg_large' st_url='<?php echo $site_url; ?>?ref=<?php echo $user->id;?>' displayText='Digg'></span>
<span class='st_delicious_large' st_url='<?php echo $site_url; ?>?ref=<?php echo $user->id;?>' displayText='Delicious'></span>
<span class='st_diigo_large' st_url='<?php echo $site_url; ?>?ref=<?php echo $user->id;?>' displayText='Diigo'></span>
<span class='st_blogger_large' st_url='<?php echo $site_url; ?>?ref=<?php echo $user->id;?>' displayText='Blogger'></span></center>
</div>
	

<!--FOOTER-->
	<div id="container">	
<a href="index.php">HOME</a> | <a href="privacy.php">PRIVACY</a> | <a href="tos.php">TERMS</a>

<p style="float:right">&copy; 2015 | Powered by <a href="http://www.viralrefer.com">VIRALREFER.COM</a></p>
	</div>	
<!--FOOTER-->	
</body>

</html>

al quale ho gia inserito nella head lo script prelevato dal file:

Codice:
/*
Post this script in <head> of index.php and active de social traffic pop

<script>

$(document).ready(function(){		
				
	$().socialTrafficPop({
		timeout: 15,
		title: "Viral Refer 2.0 - Demo",
		message: 'Share our website with your friends using the buttons below!',
		google_url: "http://www.viralrefer.com/demo/",
		fb_url: "http://www.viralrefer.com/demo/",
		closeable: false,
		advancedClose: false,
		opacity: '0.45',
		twitter_method: "tweet",
		tweet_url: 'http://www.viralrefer.com/demo/index.php?ref=1',
		tweet_text: 'Viral Refer 2.0 - Share your referral link with your friends and win amazing rewards!'
	});
	
});


</script>

*/
#stp-bg{
	display:none;
	position:fixed;
	_position:absolute; /* hack for IE 6*/
	height:100%;
	width:100%;
	top:0;
	left:0;
	background:#000000; 
	z-index:998;
}

#stp-main{
	position:fixed;
	top:220px;
	_position:absolute; /* hack for IE 6*/
	display:none;
	width:450px;
	border:7px solid #2f2f2f;
	background:#fff;
	z-index:999;
	-moz-border-radius: 9px;
	-webkit-border-radius: 9px;
	margin:0pt;
	padding:0pt;
	color:#333333;
	text-align:left;
	font-family:arial,sans-serif !important;
	font-size:13px;
}

#stp-title{
	font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif !important;
	font-size:18px;
	padding:13px 0 13px 0px;
	text-align: center;
}

#stp-close{
	float:right;
	font-size:14px;
	font-weight:bold;
	font-family:Verdana, Geneva, sans-serif;
	color:#777777 !important;
	margin:0 13px 0 0;
	border-bottom:0px !important;
	text-decoration:none !important;
}

#stp-close:hover{
	text-decoration:none !important;
}

#stp-msg{
	background:#4074CF;
	padding:10px 15px;
	color:#ffffff;
	font-family:Arial, Helvetica, sans-serif !important;
	font-weight:bold;
	line-height:20px;
	text-align: center;
}

#stp-buttons{
	margin:25px 0px 25px 0;
	padding:0 0 0 15px;
}

#stp-bottom{
	padding:15px 10px;
	background:#EFEFEF;
	color:#95989F;
	border-top:1px solid #DDE0E8;
}

#stp-counter{
	font-size:11px !important;
	text-align:right;
	font-weight:bold;
}

#stp-power{
	font-size:10px !important;
	color:#95989F;
	font-weight:normal;
	text-decoration:none;
}

#stp-power:hover{
	text-decoration:underline;
}

.stp-button{
	float:left;
	width:120px;
}

.step-clear{
	clear:both !important;
}

che pero dalle istruzioni non si capisce se devo toglierlo da questo file dopo averlo inserito in index.html

Le istruzioni sono, le seguenti:
Codice:
///////////////////////////////////////////
///////////////////////////////////////////

VIRAL REFER 2.0

///////////////////////////////////////////
///////////////////////////////////////////

Requirements:
- PHP 5+
- MYSQL 

//////////////////////////////////////////

MYSQL CODE

CREATE TABLE IF NOT EXISTS `users` (
  `id` int(11) NOT NULL auto_increment,
  `ip` text NOT NULL,
  `referrer` int(11) NOT NULL,
  `referrals` int(11) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

CREATE TABLE IF NOT EXISTS `prizes` (
  `id` int(11) NOT NULL auto_increment,
  `thumb` text NOT NULL,
  `name` text NOT NULL,
  `desc` text NOT NULL,
  `prize` text NOT NULL,
  `cost` int(11) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

//////////////////////////////////////////


---------HOW TO INSTALL VIRAL REFER 2.0------------

1º Upload all files to your web hosting server
2º Go to your panel and create a Database and user in mysql
3º Now go to the folder "inc" and edit "config.php"
4º Then go to phpmyadmin and go up to your database and upload MYSQL CODE
5º The SOCIAL TRAFFIC POP is disabled by default. To activate go until the file "social-traffic-pop.css" and follow the steps
6º Now your site is set up and working properly! Go to http://yourwebsite.com/cpadmin and create their gifts and good luck !

If you have any questions please send us an email to [email protected]

Fatto questo si deve nel file verify.php implementare un bottone per il download, nel acso che ho preparato di uno alla volta, a seconda del punteggio che ogni visitatore ottiene, di un file: cioè l'ebook in download:

il file verify.php è il seguente:

Codice:
<?php
session_start();
require_once("inc/funcs.php");
$ip = $_SERVER['REMOTE_ADDR'];
if(!isset($_GET['prizeid'])){
	header("Location: index.php");
	}else{
	$user = mysql_fetch_object(mysql_query("SELECT * FROM `$db`.`users` WHERE `ip`='". $ip ."'"));
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta charset="UTF-8">
<title>Viral Refer 2.0 - Demo</title>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
	<link rel="icon" type="image/x-icon" href="http://www.ebookwebproject.com/viralrefer/images/favicon.ico" />	
	<link rel="stylesheet" href="fonts/TitilliumText/stylesheet.css" />
	<link rel="stylesheet" href="css/style.css" />
	<meta name="Description" content="Viral Refer 2.0 - Share your referral link with your friends and win amazing rewards!" /> 
        <meta name="keywords" content="survey, online, referral, rewards, win, prize, gift, card, games">
        <meta property="og:image" content="http://www.viralrefer.com/demo/images/thumb.png"/>
</head>
<body>
			<center><h1 id="title"><a href="index.php"><span style="color:#069">«</span>Viral Refer 2.0<span style="color:#069">»</span></a><br />
			<span style="font-weight: 300; font-size: 14px; color: #27C1F4;">Share Your Link And Get Rewards</span></h1></center>			
	<br class="clear" />
	<div id="container">
				<h2>Redeem Your Reward</h2>				
<?php
	$prizeid = mysql_real_escape_string($_GET['prizeid']);
	$_SESSION['prizeid'] = $prizeid;
	if((list($id,$thumb,$name,$desc,$prize,$cost) = get_prize($prizeid)) == true){	
		if($user->referrals >= $cost){
			$_SESSION['prize'] = $prizeid;
	echo  '<p class="enough">Click the Button Below To Verify & Confirm Your Price Request</p>

<!-----------------------MONEY PAGE CONTENT OR DOWNLOAD BUTTON/WIDGET--------------------------->
<script>
function myFunction()
{
alert("VIRAL REFER 2.0 NEWS: Congratulations, you´ve managed to unlock your reward! NOTE: This is only a DEMO version, you could be redirected to a CPA offer or use a WIDGET a PPD!");
}
</script>
			<center><a href="#" class="green-pastel button heavy icon forward" onclick="myFunction()" /><span>Redeem</span></a></center>

<!-----------------------END MONEY PAGE CONTENT OR DOWNLOAD BUTTON/WIDGET----------------------->

';
		}else{
			echo '<p class="enough">You do not have enough points to purchase this item!</p><br />

					<a href="index.php" class="red button heavy icon back"><span>Go Back</span></a>';
		}
	}else{
		echo '<p class="enough">Prize does not exist in our database. Please choose a different prize.</p>

					<a href="index.php" class="red button heavy icon back"><span>Go Back</span></a>';
	}
}

?>

	</div> <!--PUSH DIVISION-->		
	<br class="clear" />		
	</div>

<!--FOOTER-->
	<div id="container">	
<a href="index.php">HOME</a> | <a href="privacy.php">PRIVACY</a> | <a href="tos.php">TERMS</a>

<p style="float:right">&copy; 2013 <a href="http://www.viralrefer.com">VIRALREFER.COM</a></p>
	</div>	
<!--FOOTER-->

</body>
</html>

tra le due righe si deve usare un bottone che visto l'id che viene richiesto e dato dal mysql mi permetta di scaricare il file.
Potrebbe essere anche un buono acquisto per inetnederci, non necessariamente deve essere un ebook...

L'ho fatta lunga e spero di essere stto piu chiaro ed un ppochino esaustivo.

Grazie per la collaborazione.
 
Nel file verify.php:

Codice:
<!-----------------------MONEY PAGE CONTENT OR DOWNLOAD BUTTON/WIDGET--------------------------->
<script>
function myFunction()
{
alert("VIRAL REFER 2.0 NEWS: Congratulations, you´ve managed to unlock your reward! NOTE: This is only a DEMO version, you could be redirected to a CPA offer or use a WIDGET a PPD!");
}
</script>
			<center><a href="#" class="green-pastel button heavy icon forward" onclick="myFunction()" /><span>Redeem</span></a></center>

<!-----------------------END MONEY PAGE CONTENT OR DOWNLOAD BUTTON/WIDGET----------------------->
Se all'ultima riga, prima del tratteggio sostituisco questa

Codice:
<center><a href="http://www.ebookwebproject.com/regali/regali.zip" class="green-pastel button heavy icon forward" onclick="myFunction()" /><span>Redeem</span></a></center>

funziona e mi permette, però un solo download.
Non ho in questo modo la scelta che deriva dal punteggio raggiunto.
In questo caso dovrei mettere a tutti e 4 i prodotti egual numero di punti e conglobarli in un unico file zip.

Ma non deve funzionare così.

fino a quì arrivo nel modo ricchiesto non so come fare.
 
Nel file verify.php:

Codice:
<!-----------------------MONEY PAGE CONTENT OR DOWNLOAD BUTTON/WIDGET--------------------------->
<script>
function myFunction()
{
alert("VIRAL REFER 2.0 NEWS: Congratulations, you´ve managed to unlock your reward! NOTE: This is only a DEMO version, you could be redirected to a CPA offer or use a WIDGET a PPD!");
}
</script>
			<center><a href="#" class="green-pastel button heavy icon forward" onclick="myFunction()" /><span>Redeem</span></a></center>

<!-----------------------END MONEY PAGE CONTENT OR DOWNLOAD BUTTON/WIDGET----------------------->

Se all'ultima riga, prima del tratteggio sostituisco questa

Codice:
<center><a href="http://www.ebookwebproject.com/regali/regali.zip" class="green-pastel button heavy icon forward" onclick="myFunction()" /><span>Redeem</span></a></center>

funziona e mi permette, però un solo download.
Non ho in questo modo la scelta che deriva dal punteggio raggiunto.
In questo caso dovrei mettere a tutti e 4 i prodotti egual numero di punti e conglobarli in un unico file zip.

Ma non deve funzionare così.

fino a quì arrivo nel modo ricchiesto non so come fare.
 
Per ora ho risolto come si vede al link:
="http://www.ebookwebproject.com/viralrefer/index.php"
Con 4 prodotti a pari punteggio.
Una volta arrivati ai 20 punti con lo sharing sui social o con le mail ed il passaparola, possono downloadare i 4 file zippati.
Ho inserito una pagina contenente il codice di un autorisponditore che una volta inseriti i dati invia una mail per la conferma di legge.
A quel punto l'autorisponditore invia un link per il download in automatico, fossero anche le 3 di mattino.
Funzionare funziona , testato, ma non è il massimo, dovrebbe avere punteggi diversi per ogni prodotto e downloadare mano mano raggiunti i benefif per i bonus.
 
Ultima modifica:

Discussioni simili