Jump to content

Recommended Posts

hey i am very new to php, and have set up a login site for votes. i need to be able to track which user logs in and dont really know how to accomplish this. the login portion works fine at the moment, as does the voting area. but i dont know where i would add the code and what it would have to consist of. My thought is that i will need a separate temp table that as the user logs on would update with their ID. As the data from the vote is being submitted the user ID would also be added to the data table. Here is the login.php

<?php

session_start();

require_once 'classes/Membership.php';

$membership = new Membership();

 

// If the user clicks the "Log Out" link on the index page.

if(isset($_GET['status']) && $_GET['status'] == 'loggedout') {

$membership->log_User_Out();

}

 

// Did the user enter a password/username and click submit?

if($_POST && !empty($_POST['username']) && !empty($_POST['pwd'])) {

$response = $membership->validate_User($_POST['username'], $_POST['pwd']);

}

 

 

?>

 

 

<!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">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>LOGIN to access HCEA voting</title>

<link rel="stylesheet" type="text/css" href="css/default.css" />

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>

<script type="text/javascript" src="js/main.js"></script>

</head>

 

<body>

<div id="login">

<form method="post" action="">

    <h2>Login <small>enter your credentials</small></h2>

        <p>

        <label for="name">Username: </label>

            <input type="text" name="username" />

        </p>

       

        <p>

        <label for="pwd">Password: </label>

            <input type="password" name="pwd" />

        </p>

       

        <p>

        <input type="submit" id="submit" value="Login" name="submit" />

        </p>

    </form>

    <?php if(isset($response)) echo "<h4 class='alert'>" . $response . "</h4>"; ?>

</div><!--end login-->

</body>

</html>

 

Link to comment
https://forums.phpfreaks.com/topic/205685-keeping-track-of-which-users-log-in/
Share on other sites

Note: Please use code tags for any code you submit - it's easier to read :P .

 

We need a little clarity on what you want to do:

1. Log which user votes for what.

2. Log every login from every user with other info like time/date/ip/browser etc.

 

For 1:

Your membership class should be able to provide you with the user id of the person voting, then your table structure should be similar to:

user_votes
---------------------------------
| id | voteqid | userid | voteaid |
---------------------------------
* voteqid - int() ID No. of the Vote row from the vote_question table.
* userid  - int() ID No. of the User that submitted the vote. (From the user table).
* voteaid - int() ID No. of the Vote Answer from the vote_answer table.

vote_questions
--------------------------------------------------------
| id | voteqname | voteqend | voteqlimit | votefinished |
--------------------------------------------------------
* voteqname    - varchar() The vote name or question (eg, Whats your favourite Colour?)
* voteqend     - int() timestamp of the time the vote will end. (When no more votes will count).
* voteqlimit   - int() Maximum number of votes before the vote closes. (No more votes will count).
* votefinished - int() timestamp that the vote ended, i suggest using 0 if the vote has not ended yet. (Default value).

vote_answers
--------------------------
| id | voteqid | voteaname |
--------------------------
* voteqid   - int() ID No. of the vote question (from the vote_question table).
* voteaname - varchar() The name of the answer (eg, Blue)

 

This way you can use advanced MySQL to handle all the data very fast and efficiently, without mixing up your tables with irrelevant data.

 

Hope this helps.

-cb-

sorry i did not clarify. i just need to log the user id with what they voted on. this site is very simple there are like four items to vote on each with three options. i have currently two tables, one for users and one for data.

users contains an id (set to auto increment), username, and password. the data table contains the four positions being voted on.

i highly reccommend using this table structure, it will save you a lot of headaches as using table columns to store the answers AND questions just isnt productive or dynamic (You should never need to add a new column unless your adding a new feature entirely).

 

So with my table structure;

 

vote.php:

<?php

// Check if user is logged in using your membership class
// Then get the userid from the membership class (should be stored in there when you log them in).
$userid = $membership->getuserid(); // Just a guess as to what the method is called.

// Check if the user has tried to vote,
if(isset($_POST['vote_submit'])){
   // Sanitize the variables (google this if you have to)
   
   // Get vote question ID (submitted with form)
   $voteqid = $_POST['voteqid'];
   // Get vote answer ID (subbmitted with the form)
   $voteaid = $_POST['voteaid'];
   
   // Check if the user has voted already
   $query = "SELECT * FROM `user_votes` WHERE `userid`='".$userid."' AND `voteqid`='".$voteqid."'";
   $result = mysql_query($query);
   if(mysql_num_rows($result) >= 1){
      echo('You have already Voted here.');
   }else{
      $query = "INSERT INTO `user_votes` (`voteqid`,`userid`,`voteaid`) VALUES ('".$voteqid."','".$userid."','".$voteaid."')";
      $result = mysql_query($query);
      if(mysql_affected_rows() >= 1){
         echo("Submitted your vote!");
      }else{
         echo("There was a problem with the Database. Your vote wasnt counted");
      }
   }
}else{
   // I assume you use the URL GET parameters to choose the Vote.
   $voteqid = $_GET['voteqid'];
   
   // Not 100% on the query - bit rusty.
   $query = "SELECT vote_questions.id, vote_questions.voteqname, vote_questions.voteqend, vote_questions.voteqlimit, vote_questions.votefinished, vote_answers.id As a_id, vote_answers.voteaname
      FROM vote_questions 
      WHERE vote_questions.id='".$voteqid."'
      LEFT JOIN vote_answers
      ON vote_questions.id=vote_answers.voteqid
      ORDER BY vote_answers.voteaname";
   
   // Execute
   $result = mysql_query($query);
   
   // Each row contains the Question information, so we only need to get one row (then reset the data pointer for the answers).
   $row = mysql_fetch_array($result);
   $voteqid = $row['id'];
   $voteqname = $row['voteqname'];
   $voteqend = $row['voteqend'];
   $voteqlimit = $row['voteqlimit'];
   $votefinished = $row['votefinished'];
   
   // Reset pointer:
   mysql_data_seek($result);
   
   // Check if we can vote:
   if($votefinished == true){
      echo("Sorry but this vote has ended.");
   }elseif($voteqend <= time() && $voteqend != 0){
      echo("This vote ended on ".date("d/m/y",$voteqend);
   }else{
      // Get number of votes for this vote question:
      $query = "SELECT `userid` FROM `user_votes` WHERE `voteqid`='".$voteqid."'";
      $numresult = mysql_query($query);
      $numvotes = mysql_num_rows($numresult);
      
      if($voteqlimit <= $numvotes){
         echo("This vote has reached its limit of ".$voteqlimit." Votes.");
      }else{
         // Give the question:
         echo($voteqname."<BR /><form method='post' action=''><input type='hidden' name='voteqid' value='".$voteqid."' />");
         // Should be able to loop each row as each answer:
         while($row = mysql_fetch_array($result)){
            echo("<input type='radio' name='voteaid' value='".$row['a_id']."' /> ".$voteaname."<BR />");
         }
         echo("<input type='submit' name='vote_submit' value='VOTE!' /></form>");
      }
   }
}

?>

 

Wow, took a little while but that should work. Not tested though.

Run through the code like a hawk - i wrote this just now for you :P So it's tailored ;).

 

-cb-

here is the html fomr i am currently using to submit the data and run the process php that origianlly input the data into mysql. what do i need to alter to accomadate the wonderful tasty bit of code you tailored for me.

 
<form id="form1" name="form1" method="post" action="process.php">

<p>President</p>
  <p>
    <label>
      <input type="radio" name="president" value="field11" id="president" />
Me</label>
    <br />
    <label>
      <input type="radio" name="president" value="field12" id="president" />
You</label>
    <br />
    <label>
      <input type="radio" name="president" value="other" id="president" />
Other </label>
    <label> 
    <input type="text" name="pres_txt" id="other" value="" size="25" />
  </p>
  <p>
    </label>
  </p>
<p>VicePresident</p>
  <p>
    <label>
    <input type="radio" name="vp" value="field21" id="vp" />
John</label>
    <br />
    <label>
    <input type="radio" name="vp" value="field22" id="vp" />
Marty</label>
    <br />
    <label>
    <input type="radio" name="vp" value="other" id="vp" />
Other</label>
    <input type="text" name="vp_txt" id="vp_txt" value="" size="25" />
    </label>
  </p>
  <p> </p>
<p>Treasurer</p>
  <p>
    <label>
    <input type="radio" name="tr" value="field31" id="tr" />
Bob</label>
    <br />
    <label>
    <input type="radio" name="tr" value="field32" id="tr" />
Rob</label>
    <br />
    <label>
    <input type="radio" name="tr" value="other" id="tr" />
Other</label>
    <input type="text" name="tr_txt" id="tr_txt" value="" size="25" />
    </label>
  </p>
<p>Sectretary</p>
  <p>
    <label>
    <input type="radio" name="sect" value="field41" id="sect" />
Richard</label>
    <br />
    <label>
    <input type="radio" name="sect" value="field42" id="sect" />
Bella</label>
    <br />
    <label>
    <input type="radio" name="sect" value="other" id="sect" />
Other</label>
    <label>
    <input type="text" name="sect_txt" id="sect_txt" value="" size="25" />
    </label>
  </p>
  <p>
    <label>
    <input type="reset" name="reset" id="reset" value="Reset" />
    <input type="submit" name="Submit" id="Submit" value="Submit" />
    </label>
    <br />
  </p>
</form>

here is the html fomr i am currently using to submit the data and run the process php that origianlly input the data into mysql. what do i need to alter to accomadate the wonderful tasty bit of code you tailored for me.

 
<form id="form1" name="form1" method="post" action="process.php">

<p>President</p>
  <p>
    <label>
      <input type="radio" name="president" value="field11" id="president" />
Me</label>
    <br />
    <label>
      <input type="radio" name="president" value="field12" id="president" />
You</label>
    <br />
    <label>
      <input type="radio" name="president" value="other" id="president" />
Other </label>
    <label> 
    <input type="text" name="pres_txt" id="other" value="" size="25" />
  </p>
  <p>
    </label>
  </p>
<p>VicePresident</p>
  <p>
    <label>
    <input type="radio" name="vp" value="field21" id="vp" />
John</label>
    <br />
    <label>
    <input type="radio" name="vp" value="field22" id="vp" />
Marty</label>
    <br />
    <label>
    <input type="radio" name="vp" value="other" id="vp" />
Other</label>
    <input type="text" name="vp_txt" id="vp_txt" value="" size="25" />
    </label>
  </p>
  <p> </p>
<p>Treasurer</p>
  <p>
    <label>
    <input type="radio" name="tr" value="field31" id="tr" />
Bob</label>
    <br />
    <label>
    <input type="radio" name="tr" value="field32" id="tr" />
Rob</label>
    <br />
    <label>
    <input type="radio" name="tr" value="other" id="tr" />
Other</label>
    <input type="text" name="tr_txt" id="tr_txt" value="" size="25" />
    </label>
  </p>
<p>Sectretary</p>
  <p>
    <label>
    <input type="radio" name="sect" value="field41" id="sect" />
Richard</label>
    <br />
    <label>
    <input type="radio" name="sect" value="field42" id="sect" />
Bella</label>
    <br />
    <label>
    <input type="radio" name="sect" value="other" id="sect" />
Other</label>
    <label>
    <input type="text" name="sect_txt" id="sect_txt" value="" size="25" />
    </label>
  </p>
  <p>
    <label>
    <input type="reset" name="reset" id="reset" value="Reset" />
    <input type="submit" name="Submit" id="Submit" value="Submit" />
    </label>
    <br />
  </p>
</form>

 

You do not need this code, The form is automatically generated using the values in the database.

Create the tables as outlined earlier, then as an example vote: (put this into php my admin one at a time)

 

INSERT INTO `vote_questions`(`id`, `voteqname`, `voteqend`, `voteqlimit`, `votefinished`)
VALUES (`1`, `Test Vote, Whats your favourite colour?`,`0`,`0`,FALSE)

INSERT INTO `vote_answers` (`id`, `voteqid`, `voteaname`)
VALUES (`1`, `1`, `Blue`)

INSERT INTO `vote_answers` (`id`, `voteqid`, `voteaname`)
VALUES (`2`, `1`, `Green`)

INSERT INTO `vote_answers` (`id`, `voteqid`, `voteaname`)
VALUES (`3`, `1`, `Red`)

INSERT INTO `vote_answers` (`id`, `voteqid`, `voteaname`)
VALUES (`4`, `1`, `Orange`)

 

Then to access your vote:

vote.php?voteqid=1

 

You can put my script on its own into "vote.php" - at the top you will need to connect to mysql and include your mmbership class, and change the line:

$userid = $membership->getuserid(); // Just a guess as to what the method is called.

 

So that it fits with your membership class.

 

-cb-

 

 

i know this is probably easy stuff here. i have taken classes in html and javascript but not php yet. my intent is this weekend to purchase a few books on both php and mysql so i am not feeling like a complete retard trying to teach myself this stuff.

You did not create the class?

 

If it is free for public use and or reproduction then you can post here - just put the author's name somewhere in the post.

 

It should be quite obvious is there is one, you could try searching for "userid" / "user id" / "username" etc.

 

Update* - Yeah getting books etc will help you a lot if you follow them through, but dont be thrown off by trying stuff out yourself, because the harder you find it, the better you will feel when you accomplish your task.

 

-cb-

that is kinda what i have been doing experimenting with changing the codes and adding to them that is how i have gotten what i currently have to work. trial, experimentation and error... lots and lots of error. lol the login code is from this site http://net.tutsplus.com/articles/news/how-to-build-a-login-system-for-a-simple-website/

totally not my own design, i figured if i could find enough pieces of code that was similar i could peice them together to make my own piece that accomplished what i needed it too. however, i have found out that coding is like construction everyone does it slightly different even though the outcome may be the same.

ok i found the class folder

<?php

require_once 'includes/constants.php';

class Mysql {
private $conn;

function __construct() {
	$this->conn = new mysqli(DB_SERVER, DB_USER, DB_PASSWORD, DB_NAME) or 
				  die('There was a problem connecting to the database.');
}

function verify_Username_and_Pass($un, $pwd) {

	$query = "SELECT *
			FROM users
			WHERE username = ? AND password = ?
			LIMIT 1";

	if($stmt = $this->conn->prepare($query)) {
		$stmt->bind_param('ss', $un, $pwd);
		$stmt->execute();

		if($stmt->fetch()) {
			$stmt->close();
			return true;
		}
	}

}
}

this was in it along with the membership.php which i think i already posted

i was wrong i posted the login.php here is the membership.php

<?php

require 'Mysql.php';

class Membership {

function validate_user($un, $pwd) {
	$mysql = New Mysql();
	$ensure_credentials = $mysql->verify_Username_and_Pass($un, md5($pwd));

	if($ensure_credentials) {
		$_SESSION['status'] = 'authorized';
		header("location: index.php");
                   } else return "Please enter a correct username and password";

} 

function log_User_Out() {
	if(isset($_SESSION['status'])) {
		unset($_SESSION['status']);

		if(isset($_COOKIE[session_name()])) 
			setcookie(session_name(), '', time() - 1000);
			session_destroy();
	}
}

function confirm_Member() {
	session_start();
	if($_SESSION['status'] !='authorized') header("location: login.php");
}

}

Ok, apart from the code that you got is not inline with standard OOP practice (which just niggles me), there is actually no userid method (which also niggles me :P).

 

So you need to modify the authorize method inside the class inside membership.php like so:

<?php

require 'Mysql.php';

class Membership {

private $current_userid;

function validate_user($un, $pwd) {
	$mysql = New Mysql();
	$ensure_credentials = $mysql->verify_Username_and_Pass($un, md5($pwd));

	if($ensure_credentials !== false) {
		$_SESSION['status'] = 'authorized';
		header("location: index.php");
	} else return "Please enter a correct username and password";

} 

function log_User_Out() {
	if(isset($_SESSION['status'])) {
		unset($_SESSION['status']);

		if(isset($_COOKIE[session_name()])) 
			setcookie(session_name(), '', time() - 1000);
			session_destroy();
	}
}

function confirm_Member() {
	session_start();
	if($_SESSION['status'] !='authorized') header("location: login.php");
}

function get_userid() {
	return $this->current_userid;
}
}

?>

 

So also you will need to modify mysql.php class method like so (you should never need to do this.. which niggles me):

<?php

require_once 'includes/constants.php';

class Mysql {
private $conn;

function __construct() {
	$this->conn = new mysqli(DB_SERVER, DB_USER, DB_PASSWORD, DB_NAME) or 
				  die('There was a problem connecting to the database.');
}

function verify_Username_and_Pass($un, $pwd) {

	$query = "SELECT `id` 
			FROM users
			WHERE username = ? AND password = ?
			LIMIT 1";

	if($stmt = $this->conn->prepare($query)) {
		$stmt->bind_param('ss', $un, $pwd);
		$stmt->execute();

		$stmt->bind_result($userid);

		if($stmt->fetch()) {
			$stmt->close();
			return $userid;
		}
	}
	return false;

}
}

?>

 

Take note of the changes and why they are there. Also think about reading a lot of tutorials on php so you know why this code isnt exactly standard.

 

-cb-

lol thanks i truly appreciate you taking the time to help me, you rock. i fully intend by the end of summer to be fluent in php, because this site which i thought would be easy cheesy has made me feel like a complete retard... :P

ok i got the code all squared away and added the tables and ran it for the first time. i am getting an a parse error: syntax error, unexpected ';' in /var/www/vote.php on line 63. as far as i can tell the syntax is correct but i guess it is not or it would work. i allivated that portion of the code and it jumped to the next if statement and gives the same error.

Ok so, lets make sure this is right:

 

Your SQL Table structure

(save this text as a ".sql" file and use phpmyadmin to import it into your membership database)

-- phpMyAdmin SQL Dump
-- version 3.3.3
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jun 25, 2010 at 02:22 PM
-- Server version: 5.1.48
-- PHP Version: 5.3.2

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

--
-- Database: `membership`
--

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

--
-- Table structure for table `users`
--

CREATE TABLE IF NOT EXISTS `users` (
  `id` int(255) NOT NULL AUTO_INCREMENT,
  `username` varchar(255) NOT NULL,
  `password` varchar(255) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `username` (`username`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

--
-- Dumping data for table `users`
--

INSERT INTO `users` (`id`, `username`, `password`) VALUES
(1, 'chemicalbliss', '098f6bcd4621d373cade4e832627b4f6');

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

--
-- Table structure for table `user_votes`
--

CREATE TABLE IF NOT EXISTS `user_votes` (
  `id` int(255) NOT NULL AUTO_INCREMENT,
  `voteqid` int(255) NOT NULL,
  `userid` int(255) NOT NULL,
  `voteaid` int(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

--
-- Dumping data for table `user_votes`
--


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

--
-- Table structure for table `vote_answers`
--

CREATE TABLE IF NOT EXISTS `vote_answers` (
  `id` int(255) NOT NULL AUTO_INCREMENT,
  `voteqid` int(255) NOT NULL,
  `voteaname` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

--
-- Dumping data for table `vote_answers`
--


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

--
-- Table structure for table `vote_questions`
--

CREATE TABLE IF NOT EXISTS `vote_questions` (
  `id` int(255) NOT NULL AUTO_INCREMENT,
  `voteqname` varchar(255) NOT NULL,
  `voteqend` int(15) NOT NULL,
  `voteqlimit` int(255) NOT NULL,
  `votefinished` tinyint(1) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

--
-- Dumping data for table `vote_questions`
--

 

 

Fixing The vote.php Script

Fix #1 - Add your membership authorize code and database connection code at the top of the script like so:

<?php
// Check if user is logged in using your membership class
require_once 'classes/Membership.php';
$membership = New Membership();
$membership->confirm_Member();

// Connect to mysql
$mysql = New Mysql();

// Then get the userid from the membership class (should be stored in there when you log them in).
$userid = $membership->get_userid(); // Just a guess as to what the method is called.
...

* Note: I have also modified the getuserid method to match the name used (with _) in membership.php class.

 

Fix #2 - Add a few lines in vote.php so that you have a default page like so:

	
if(!isset($_GET['voteqid'])){
	exit("Please select a Question Vote ID:
	<form action='' method='GET'><input type='text' name='voteqid' /><input type='submit' value='Find Vote' /></form>");
}

// I assume you use the URL GET parameters to choose the Vote.
$voteqid = $_GET['voteqid'];

 

Fix #3 - Fix the mysql query like so:

	// Not 100% on the query - bit rusty.
$query = "SELECT vote_questions.id, vote_questions.voteqname, vote_questions.voteqend, vote_questions.voteqlimit, vote_questions.votefinished, vote_answers.id As a_id, vote_answers.voteaname
	FROM vote_questions 
	LEFT JOIN vote_answers
	ON vote_questions.id=vote_answers.voteqid
	WHERE vote_questions.id='".$voteqid."'
	ORDER BY vote_answers.voteaname";

 

Fix #4 - Just in case there is an error with the query, modify the next lines like so:

	// Execute
$result = mysql_query($query) or die(mysql_error()."<br /><br />\n\n".$query);

 

Fix #5 - Fix the argument count error for mysql_Data_seek like so:

	// Reset pointer:
mysql_data_seek($result, 0);

 

Fix #6 - The syntax error was pretty straight-forward, I missed a closing parenthesis near the end of line 63:

		echo("This vote ended on ".date("d/m/y",$voteqend));

 

Fix #7 - Then modify the voteqlimit statement, so that a 0 in the voteqlimit field will mean no limit:

		if($voteqlimit <= $numvotes && $voteqlimit != 0){
		echo("This vote has reached its limit of ".$voteqlimit." Votes.");
	}else{

 

Fix #8 - Finally, Modify the echo line that prints the Radio button to fix the undefined variable error:

				echo("<input type='radio' name='voteaid' value='".$row['a_id']."' /> ".$row['voteaname']."<BR />");

 

Modifying the classes/membership.php class file

Modification #1 - Add this method to the class above or below another method/function:

	// returns the userid in the session variable
function get_Userid() {
	return $_SESSION['userid'];
}

 

Modification #2 - Modify the validate_user method:

	function validate_user($un, $pwd) {
	$mysql = New Mysql();
	$userid = $mysql->verify_Username_and_Pass($un, md5($pwd));

	if($userid !== false) { // Modified to Not Match a Literal Boolean False.
		$_SESSION['userid'] = $userid; // Add Session Variable (userid)
		$_SESSION['status'] = 'authorized';
		header("location: index.php");
	} else return "Please enter a correct username and password";

} 

 

Modifying the classes/mysql.php class file

We are going to make this connection using Procedural MYSQL (easier to learn for you, much easier).

 

Modification #1 - Add this to the top of the verify_Username_and_Pass Function:

		// Make safe for MySQL.
	$user = mysql_real_escape_string($un, $this->conn);
	$pass = mysql_real_escape_string($pwd, $this->conn);

 

Modification #2 - Modify the Query like so:

		$query = "SELECT `id`
			FROM users
			WHERE username = '$user' AND password = '$pass'
			LIMIT 1";

 

Modification #3 - After the query, Modify the whole Statement block in that same function like so:

		//Execute the Query
	$result = mysql_query($query, $this->conn);

	// MySQL's method of checking for success
	if(mysql_num_rows($result, $this->conn) >= 1){ // 1 or more rows returned/matched
		return mysql_result($result, 0, 'id');
	}

	// otherwise
	return false;

 

Once you have made the modifications - Log out, then log in again.

 

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

Testing The New Script

To get you started, execute these queries in phpmyadmin one by one (Make sure they are new tables with no data)

 

INSERT INTO `membership`.`vote_questions` (`id`, `voteqname`, `voteqend`, `voteqlimit`, `votefinished`) VALUES (1, 'What is your favourite colour?', '0', '0', '0');

INSERT INTO `membership`.`vote_answers` (`id`, `voteqid`, `voteaname`) VALUES (NULL, '1', 'red'), (NULL, '1', 'blue');

 

Then, visit vote.php. Type the id from the "vote_questions" table, in the SQL case above: "1".

 

Voila!

(wow, that took a long time to format - lol)

-cb-

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.