Jump to content

making a poll for my site


SFB

Recommended Posts

ok so basically i have the poll made but i was wondering if you the reader of this post was downloading my poll to use on your site, would you want an admin pannel or would you rather do the editing of questions and answers in the code yourself. An admin pannel would be lots of extra work and would require a way to make it secure so that other users cant create polls that you may not want.

Link to comment
Share on other sites

if you are developing some kind of "application" to distribute online will be better with a backoffice.Imagine that a kid wants use your poll but he doesn't know nothing about html/php. will be easier with a page to configure the poll options.don't worry about security. make online a page to setup de database values for poll options.

Link to comment
Share on other sites

Um, this isnt hard to do, I made a quick poll for my site. Well, I took it from zend.com's beginner tut lol. But I already had an admin center and I just stuck it in that page :).

Link to comment
Share on other sites

Um, this isnt hard to do, I made a quick poll for my site. Well, I took it from zend.com's beginner tut lol. But I already had an admin center and I just stuck it in that page :).
This is why i am hesitating to add my own. many people alredy have some sort of admin center.
if you are developing some kind of "application" to distribute online will be better with a backoffice.Imagine that a kid wants use your poll but he doesn't know nothing about html/php. will be easier with a page to configure the poll options.don't worry about security. make online a page to setup de database values for poll options.
I dont think of this as an application as much as an add-on to someone's website so then they should at least have general html knowlage. security should always be an issue, the world isnt perfect. eventually somone will figure out the location of the admin center. i will make a simple admin page just to create polls but it can be disabled, the user will have to change something in the file like $disable = 'FALSE'; to $disable = 'TRUE';
Link to comment
Share on other sites

ok here is the code to create a poll but i cant seem to get the fopen to work.

<html><head><title>Create-A-Poll</title></head><body><?phpif (!isset($_POST['question'])) {  echo "<form action='index.php' method='post'>Name of file: <input type='text' name='file' /><br />Question: <input type='text' name='question' /><br />";  for ($i = 1; $i <= 10; $i++) {    echo "answer".$i.": <input type='text' name='answer".$i."' /><br />";  }  echo "<input type='submit' value='submit' /></form><br /><div>Leave extra fields blank</div>";}else{  $question = $_POST['question'];  $filename = $_POST['file'];  $str = "<" . "?php\n";  $str .= "\$answers = array(answer, votes);\n";  $str .= "\$answers['answer'] = array();\n";  $str .= "\$answers['votes'] = array();\n";  $str .= "\$question = \"" . $question . "\";\n";  for ($i = 1; $i <= 10; $i++) {    if (isset($_POST["answer$i"])) {      $input = $_POST["answer$i"];      $votes = 0;      $str .= "\$answers['answer'][] = \"" . $input . "\";\n";      $str .= "\$answers['votes'][] = \"" . $votes . "\";\n";    }  }$str .= "?" . ">";if (!$handle = fopen($filename, "w")) {  echo "We are sorry please go back and try again.  If this problem occurs again please contact the administrator<!--001(fopen)-->";  exit;}if (fwrite($handle, $str) === FALSE) {  echo "We are sorry please go back and try again.  If this problem occurs again please contact the administrator<!--002(fwrite)-->";  exit;}fclose($handle);}?></body></html>

it always gives me my error message.

Link to comment
Share on other sites

One thing is to change this:$str .= "\$answers = array(answer, votes);\n";remove the answer and votes there. If you wanted, they should be quoted, but it still doesn't do what you think. These three lines: $str .= "\$answers = array('answer', 'votes');\n"; $str .= "\$answers['answer'] = array();\n"; $str .= "\$answers['votes'] = array();\n";would produce this:array(0 => 'answer', 1 => 'votes', 'answer' => Array, 'votes' => Array)For the fopen, print out the filename and make sure it exists.

Link to comment
Share on other sites

O um yeah i dont know why i was thinking that that would well it doesn't thanks for pointing that out. for the fopen the filename shouldn exist. i wanted to create the file. i thought that the 'w' in the fopen ment open for wrighting if doesent exsist try and create it.

Link to comment
Share on other sites

I see. Well, at least make sure that the filename is a legal filename. Other than that, I would say to turn on errors so that you know what is going on. It's a little silly to develop on a server without errors on. You can use ini_set to set display_errors to 1 on your page.

Link to comment
Share on other sites

I see. Well, at least make sure that the filename is a legal filename. Other than that, I would say to turn on errors so that you know what is going on. It's a little silly to develop on a server without errors on. You can use ini_set to set display_errors to 1 on your page.
i am 99% sure that test.php would be a legal filename. i even tried /test.php and a real location but it didnt work. i cant figure out what is up. i just entered in a filename in qoutes in the actual code for testing so i knew it wasnt the form. i took this part of the script directly from the login page then modified the location and the error message. it should work. i tested it without the if statement to see it the if was causing it to not create the file but it didnt work. i should check the permissions on the directory... i bet that is it. I cant use ini_set... it doesnt work. get an account at dcole.ath.cx and see. dan doesnt want to go throught the extra work of figuring out how to do it so if i want it i have to explin how it is done and then hope that he does it corectly and if he doesnt then i have to try and figure out what went wrong. i was the one who had to figure out how dan could host multiple domains.Edit: yep it was the permissions on both the file and the folder. for some reason it only had write on the user and not on group. i fixed it.
Link to comment
Share on other sites

I don't even know how it's possible to disable ini_set, I can't find any documentation on it. He had to do it somehow, does he not know how he did it? What do you mean it doesn't work, what happens when you try to do it? How did he install and set up PHP? Did he do it himself? And are you telling me that your host is so lazy that he wants you to do the work for him to get his server configured? You can always just set up your own test server, configure it how you want, and move things over to your host once you have them working.Never mind. There is a disable_functions directive in php.ini and ini_set is probably listed there. He could have found that by searching php.ini for ini_set, or even by just reading through php.ini.

Link to comment
Share on other sites

I don't even know how it's possible to disable ini_set, I can't find any documentation on it. He had to do it somehow, does he not know how he did it? What do you mean it doesn't work, what happens when you try to do it? How did he install and set up PHP? Did he do it himself? And are you telling me that your host is so lazy that he wants you to do the work for him to get his server configured? You can always just set up your own test server, configure it how you want, and move things over to your host once you have them working.Never mind. There is a disable_functions directive in php.ini and ini_set is probably listed there. He could have found that by searching php.ini for ini_set, or even by just reading through php.ini.
I'd like to say he is too lazy but currently he isnt working on hosting as much as he is working on his search engine. over time he probably would go figure out how to configure it but if i wanted it that hour/day i had to do it. ini_set seems to work now. must have been doing something wrongI had xampp but then got rid of it for lack of use and it was slowing down my computer on startup. i would login and then have to wait an extra amount of time before other programs would open.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...