Jump to content

[SOLVED] Dont Display Link if already clicked


jnerotrix

Recommended Posts

  • Replies 76
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

i dont know how to develop this code :sorry: its kinda confusing to explain

 

Ok theres a page with a list of surveys

 

and it would look like this:

----------------------

 

<a href="#">Survey 1 </a>

<a href="#">Survey 2 </a>

<a href="#">Survey 3 </a>

<a href="#">Survey 4 </a>

<a href="#">Survey 5 </a>

 

--------------

I want it so if say the user click Survey 1 it would take them to that page but when they go back it wont display Survey 1 anymore because the user has already clicked it

 

can this be done with a code or can i use mysql to display links or something

 

 

Thanks,

Jnerotrix

Link to comment
Share on other sites

It can be done, but there;s a lot of code for someone who seem to have a huge knowledge of php.

 

I don't think anyone is going to write the code for you.

 

Did you build your user login system yourself? If so we can probably start from there!

Link to comment
Share on other sites

yea but i cheated i took bits and pieces of other people codes and just put them together

 

the login system is fully functional

 

--------------------

Files with my login system

login.php

main.php (default after login page) I changed it to index.php though

process.php (logout)

register.php

userinfo.php ( is a very simple public profile )

useredit.php ( user can edit their email & Password)

 

Directory: (admin)

admin.php (main admin page) (1st registered user is admin u can also set other admins in admin panel

*ban users

*Delete Users that have been inactive for (Certain Number of Days)

adminprocess.php (process all the admin.php forms)

 

then for the Mysql Stuff Directory : Folder is "include"

constants.php

database.php

form.php

mailer.php

session.php (you include this file on all the pages you want the user session)

view_acrive.php (this shows active members and guests viewing site)

 

 

Link to comment
Share on other sites

Are you wanting the links to permanently be hidden for the user once he takes the survey, or just for that login session, as in, he can log out and log back in and it be available again?  Or maybe it will be available again tomorrow or next week or something?  Part of getting help is being specific with what you want.

Link to comment
Share on other sites

well actually i have already done this with user sessions on the main index page

 

Heres the index page code:

 

If user is logged in it shows surveys else displays main login page

 

(Permanantly Hidden)

 

<?
include("include/session.php");
?>

<html>
<head>

<style>
.shakeimage{
position:relative
}
</style>
<script language="JavaScript1.2">

/*
Shake image script (onMouseover)- 
© Dynamic Drive (www.dynamicdrive.com)
For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/

//configure shake degree (where larger # equals greater shake)
var rector=3

///////DONE EDITTING///////////
var stopit=0 
var a=1

function init(which){
stopit=0
shake=which
shake.style.left=0
shake.style.top=0
}

function rattleimage(){
if ((!document.all&&!document.getElementById)||stopit==1)
return
if (a==1){
shake.style.top=parseInt(shake.style.top)+rector
}
else if (a==2){
shake.style.left=parseInt(shake.style.left)+rector
}
else if (a==3){
shake.style.top=parseInt(shake.style.top)-rector
}
else{
shake.style.left=parseInt(shake.style.left)-rector
}
if (a<4)
a++
else
a=1
setTimeout("rattleimage()",50)
}

function stoprattle(which){
stopit=1
which.style.left=0
which.style.top=0
}

</script>
</head>
<title> EpicBux Survey Site </title>
<body>
<center>
<?php

if($session->logged_in){

?>

<img src="./logo.gif"><br>
<a href="./index.php"><img src="./images/btn-home.gif" border="0" class="shakeimage" onMouseover="init(this);rattleimage()" onMouseout="stoprattle(this);top.focus()" onClick="top.focus()"></a>
<a href="./login.php"><img src="./images/btn-login.gif" border="0" class="shakeimage" onMouseover="init(this);rattleimage()" onMouseout="stoprattle(this);top.focus()" onClick="top.focus()"></a>
<a href="./advertise.php"><img src="./images/btn-ad.gif" border="0" class="shakeimage" onMouseover="init(this);rattleimage()" onMouseout="stoprattle(this);top.focus()" onClick="top.focus()"></a>
<a href="./register.php"><img src="./images/btn-signup.gif" border="0" class="shakeimage" onMouseover="init(this);rattleimage()" onMouseout="stoprattle(this);top.focus()" onClick="top.focus()"></a><br>
<img src="./bgimage.gif">
<?
} else {

?>

<img src="./logo.gif"><br>
<a href="./index.php"><img src="./images/btn-home.gif" border="0" class="shakeimage" onMouseover="init(this);rattleimage()" onMouseout="stoprattle(this);top.focus()" onClick="top.focus()"></a>
<a href="./advertise.php"><img src="./images/btn-ad.gif" border="0" class="shakeimage" onMouseover="init(this);rattleimage()" onMouseout="stoprattle(this);top.focus()" onClick="top.focus()"></a>
<a href="./process.php"><img src="./images/btn-logout.gif" border="0" class="shakeimage" onMouseover="init(this);rattleimage()" onMouseout="stoprattle(this);top.focus()" onClick="top.focus()"></a><br>
<table height="440" width="873" border="1">
<table height="400" width="800" bgcolor="green" align="center">
<tr>
<td> Welcome<?php echo "$session->username"; ?></td>
</tr>
<tr>
<td> EpicBux is aGreat New Survey Site Where you can make money easily online by filling out some simple forms and givind friend refferals links
</td>
</tr>
</table>
<tr>
<td><h1> Surveys Available </h1></td>
</tr>
<tr>
<td> <a href="#"> Survey Dec-1 = $0.80 </a></td>
</tr>
<tr>
<td> <a href="#"> Survey Dec-2 = $0.80 </a></td>
</tr>
</table>
<?

}

?>


</body>
</html>

 

 

 

Link to comment
Share on other sites

At the moment your surveys show when the user is logged out (or at least that's how it looks)

 

You need to sort that code out, if the user is logged in they just see a nav, if they're not logged in they see the same nav, and the surveys, as well as attempting to display a username.

Link to comment
Share on other sites

Sorry i always write it backwards now its fixed

 

 

<?
include("include/session.php");
?>

<html>
<head>

<style>
.shakeimage{
position:relative
}
</style>
<script language="JavaScript1.2">

/*
Shake image script (onMouseover)- 
© Dynamic Drive (www.dynamicdrive.com)
For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/

//configure shake degree (where larger # equals greater shake)
var rector=3

///////DONE EDITTING///////////
var stopit=0 
var a=1

function init(which){
stopit=0
shake=which
shake.style.left=0
shake.style.top=0
}

function rattleimage(){
if ((!document.all&&!document.getElementById)||stopit==1)
return
if (a==1){
shake.style.top=parseInt(shake.style.top)+rector
}
else if (a==2){
shake.style.left=parseInt(shake.style.left)+rector
}
else if (a==3){
shake.style.top=parseInt(shake.style.top)-rector
}
else{
shake.style.left=parseInt(shake.style.left)-rector
}
if (a<4)
a++
else
a=1
setTimeout("rattleimage()",50)
}

function stoprattle(which){
stopit=1
which.style.left=0
which.style.top=0
}

</script>
</head>
<title> EpicBux Survey Site </title>
<body>
<center>
<?php

if($session->logged_in){

?>

<img src="./logo.gif"><br>
<a href="./index.php"><img src="./images/btn-home.gif" border="0" class="shakeimage" onMouseover="init(this);rattleimage()" onMouseout="stoprattle(this);top.focus()" onClick="top.focus()"></a>
<a href="./advertise.php"><img src="./images/btn-ad.gif" border="0" class="shakeimage" onMouseover="init(this);rattleimage()" onMouseout="stoprattle(this);top.focus()" onClick="top.focus()"></a>
<a href="./process.php"><img src="./images/btn-logout.gif" border="0" class="shakeimage" onMouseover="init(this);rattleimage()" onMouseout="stoprattle(this);top.focus()" onClick="top.focus()"></a><br>
<table height="440" width="873" border="1">
<table height="400" width="800" bgcolor="green" align="center">
<tr>
<td> Welcome<?php echo "$session->username"; ?></td>
</tr>
<tr>
<td> EpicBux is aGreat New Survey Site Where you can make money easily online by filling out some simple forms and givind friend refferals links
</td>
</tr>
</table>
<tr>
<td><h1> Surveys Available </h1></td>
</tr>
<tr>
<td> <a href="#"> Survey Dec-1 = $0.80 </a></td>
</tr>
<tr>
<td> <a href="#"> Survey Dec-2 = $0.80 </a></td>
</tr>
</table>

<?
} else {

?>

<img src="./logo.gif"><br>
<a href="./index.php"><img src="./images/btn-home.gif" border="0" class="shakeimage" onMouseover="init(this);rattleimage()" onMouseout="stoprattle(this);top.focus()" onClick="top.focus()"></a>
<a href="./login.php"><img src="./images/btn-login.gif" border="0" class="shakeimage" onMouseover="init(this);rattleimage()" onMouseout="stoprattle(this);top.focus()" onClick="top.focus()"></a>
<a href="./advertise.php"><img src="./images/btn-ad.gif" border="0" class="shakeimage" onMouseover="init(this);rattleimage()" onMouseout="stoprattle(this);top.focus()" onClick="top.focus()"></a>
<a href="./register.php"><img src="./images/btn-signup.gif" border="0" class="shakeimage" onMouseover="init(this);rattleimage()" onMouseout="stoprattle(this);top.focus()" onClick="top.focus()"></a><br>
<img src="./bgimage.gif">


<?

}

?>


</body>
</html>

Link to comment
Share on other sites

Make sure you use full tags <?php not <? when opening

 

Next you're going to need to make a new table in your database.

 

Are you going to be adding surveys over time? Or will there be a set amount? The answer to this will be the difference between needing 1 or 2 tables.

Link to comment
Share on other sites

OK, first table

 

CREATE TABLE `test`.`surveys` (
`id` INT NOT NULL AUTO_INCREMENT ,
`title` VARCHAR( 32 ) NOT NULL ,
PRIMARY KEY ( `id` )
) ENGINE = MYISAM 

 

second table

 

CREATE TABLE `test`.`completed_surveys` (
`member_id` INT NOT NULL ,
`survey_id` INT NOT NULL
) ENGINE = MYISAM 

 

Have a look at the tables once their made and see if they make sense to you!?

Link to comment
Share on other sites

The easiest option I think will be to manually add your new surveys to the first table, It seems like more effort than necessary to make an area for you to add them!!

 

So go into phpMyAdmin and go the surveys table

 

Input a line, leave id blank and write in the title of your first survey (do this for all your surveys)

Link to comment
Share on other sites

I wrote one this should work right?

 

<?php
include("include/session.php");
?>

<?php

if (isset($_POST['action'])) {


mysql_connect("localhost", "USER", "PASS") or die(mysql_error());
mysql_select_db("sex1800_loginbux") or die(mysql_error());


mysql_query("INSERT INTO title 
(title) VALUES('$title') ") 
or die(mysql_error());  

echo "Survey Added!";

}

?>


<html>
<head>
</head>
<title> Add a Survey </title>
<center>
<?php 

if($session->isAdmin()){

?>



<table border="1">
<tr>
<td>Survey Title: <input type="text" name="title"></td>
</tr>
<tr>
<td><input type="submit" value="Add Survey"></td>
<input type='hidden' name='submitted' value='yes'>
</tr>
</form>
</table>



<?php
} else {

echo 'You Must Be An Administrator to add a Survey';

}

?>



Link to comment
Share on other sites

i forgot to define title i fixed it:

 

 

<?php
include("include/session.php");
$self = $_SERVER['PHP_SELF'];
?>

<?php



if (isset($_POST['action'])) {

$title = $_POST['title'];


mysql_connect("localhost", "sex1800_admin", "----------") or die(mysql_error());
mysql_select_db("sex1800_loginbux") or die(mysql_error());


mysql_query("INSERT INTO title 
(title) VALUES('$title') ") 
or die(mysql_error());  

echo "Survey Added!";

}

?>


<html>
<head>
</head>
<title> Add a Survey </title>
<center>
<?php 

if($session->isAdmin()){

?>



<table border="1">
<form action="$self" method="post">
<tr>
<td>Survey Title: <input type="text" name="title"></td>
</tr>
<tr>
<td><input type="submit" value="Add Survey"></td>
<input type='hidden' name='submitted' value='yes'>
</tr>
</form>
</table>



<?php
} else {

echo 'You Must Be An Administrator to add a Survey';

}

?>



Link to comment
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.