Jump to content

darksniperx

Members
  • Posts

    113
  • Joined

  • Last visited

    Never

Everything posted by darksniperx

  1. if($_POST['submit']) { /*comment code temporarely foreach($_POST['name'] as $value) { echo $value; } */ $name = $_POST['name']; $email = $_POST['email']; $website = $_POST['website']; for($posion = 0; $position < count($name); $position ++) { echo $name[$position] . " : - : " . $email[$position] . " : - : " .$website[$position] ."\n"; } } when I use for each everything works and I get output, the problem, it works only with one variable. Since I have to work with 3 variables arrays I have switched to for look, but I get no output???
  2. <!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>add/remove text boxes script</title> </head> <body> <script type="text/javascript"> var userInput_boxes = 1; function removeElement(id) { document.getElementById(userInput[id]).parentNode.removeChild(document.getElementById(userInput[id])); } function addElement() { var input = document.getElementById("name"); var user = document.createElement("input"); //var cellText = document.createTextNode("only text ids display, no innerHTML?"); user.setAttribute("type","text"); user.setAttribute("value","inputbox"); user.setAttribute('name','userName[]'); user.setAttribute("id","userInput['userInput_boxes']"); input.appendChild(user); userInput_boxes = userInput_boxes + 1; var a = document.createElement("a"); var id = userInput_boxes - 1; //alert(id); a.setAttribute("href","javascript:removeElement('id');"); aText = document.createTextNode("remove"); a.appendChild(aText); input.appendChild(a); var br = document.createElement("br"); input.appendChild(br); } </script> <form action="" method="post"> <a href="javascript:addElement();">add</a> <div id="name"> </div> </form> </body> </html> add input code tag works, it is remove input tag that gives trouble, I think something is setAttribute, but I cant figure out. Also i would like to know if I would submit the page would it submit the newly create input tags as well for me to work with.
  3. i have used id to solve it: <label><input type='checkbox' name='cat_id[]' id ='category_id' value='5'/>Drinks</label> thx, it works now!!!
  4. thx, I used part of your code to get mine to work.
  5. if I do it in that form, then I get an error calling document.entry_form.cat_id[i].checked = true;// it complains about [] brackets
  6. on my html form, I have <label><input type='checkbox' name='cat_id' value='1'/>Food</label> <label><input type='checkbox' name='cat_id' value='2'/>Gas</label> <label><input type='checkbox' name='cat_id' value='3'/>Religion</label> <label><input type='checkbox' name='cat_id' value='4'/>Chips</label> <label><input type='checkbox' name='cat_id' value='5'/>Drinks</label> on my php side I have foreach ($_POST["cat_id"] as $value) //gives error for cat_id { $this->fusion->addToFetcategory($feed_id,$entry_id,$value); } before I used: <label><input type='checkbox' name='cat_id[]' value='5'/>Drinks</label> but due to that I needed to use the array with dom I had it to: <label><input type='checkbox' name='cat_id' value='5'/>Drinks</label> in order to use : for (var i=0; i < document.entry_form.cat_id.length; i++) { if (document.entry_form.cat_id[i].value == current_id ) { document.entry_form.cat_id[i].checked = true; } } what can I do to get my foreach php code working again?
  7. What I would like to do this. I need to create a way to generate html code with a button click. For example, I would like to create a list of people's name with their emails and remove any of them at any time. part of the code would look something like this: <a href="javascript:add();">Add Field</a> <div id='people'> Name:<input type='text' name='name[]' /> Email:<input type='text' name='email[]' /><a href="javascript:remove();">Remove Field</a><br/> </div> When ever someone clicks add field, the code adds the following line inside div tag When ever someone clicks remove field, the code will remove that its line from div tag. the second part, is that I would like to pass the array to of name and email to php and work with them foreach($_POST['name'] as $name, $_POST['email'] as $email) { // do the following } and also that they would be synchronized together, that email would belong to the to its name and not to any other onces in the array. original post: http://www.phpfreaks.com/forums/index.php/topic,169355.0.html
  8. what I need to do is while I am retrieving data from database, is to check correct boxes. the following code is of the checkboxes that are displayed on my webpage <label><input type='checkbox' name='cat_id[]' value='1'/>Food</label><label><input type='checkbox' name='cat_id[]' value='2'/>Gas</label> <php ... while($category_row = mysql_fetch_array($category_table)) { ?> category_id = '<?php echo $category_row['cat_id'];?>'; <script type='text/javascript'> document.GetElementById['cat_id'].checked = 'true'; </script> <?php } what I need to do is to fix js script, so that it would take the value from category_id, find check box with the same value and set checked to true
  9. What I would like to do this. I need to create a way to generate html code with a button click. For example, I would like to create a list of people's name with their emails and remove any of them at any time. part of the code would look something like this: <a href="javascript:add();">Add Field</a> <div id='people'> Name:<input type='text' name='name[]' /> Email:<input type='text' name='email[]' /><a href="javascript:remove();">Remove Field</a><br/> </div> When ever someone clicks add field, the code adds the following line inside div tag When ever someone clicks remove field, the code will remove that its line from div tag. the second part, is that I would like to pass the array to of name and email to php and work with them foreach($_POST['name'] as $name, $_POST['email'] as $email) { // do the following } and also that they would be synchronized together, that email would belong to the to its name and not to any other onces in the array.
  10. if query was successfull, meaning there were no errors during query, and if rows were found or not
  11. $result = mysql_query("SELECT * FROM feed WHERE feed_id = '$id'"); if(!$result) { die("query unsuccessfull"); } else { echo'queury successfull'; } something along these lines, but to be able to check any kind of query, add, delete, update,... the example above does not work me.
  12. your code works, also I have remembered to use ?> <script>window.setTimeout('window.location="index.php?page=main_page"; ',2000);</script>"; <?php
  13. echo " <script>window.setTimeout('window.location='index.php?page=main_page'; ',2000);</script>"; I had too much trouble with header php header, so I switched to js.
  14. when I runned main_page-> index.php?page=main_page Check for file exists succeded0 1 Index page or page not found matches when I funned with Feed Check for file exists succeded-1 1 Need to redirect to Unlogged page it seems that the code is working, going to the right direction, untill it reaches header.
  15. at the moment right now, I cant even view the error , because as soon as the code gets to header( 'Location: index.php?page=unlogged' ); I get page cannot be found, dns, error, and echo does not help anymore. if I comment out header( 'Location: index.php?page=unlogged' ); then I can view unlogged page. sorry for double post, could not edit the previous one.
  16. my guess that i had to clear header buffer. I have added the line, and still get dns error I have reread the link that you have sent me, and buffering header files still doesnt help me, it did not show the error message that I got with echo, but the problem php pointing out dns errors is still there, and on the same line: header( 'Location: index.php?page=unlogged' );s
  17. I get the following message Entry Warning: Cannot modify header information - headers already sent by (output started at /home/user/public_html/alex/alpha3/index.php:27) in /home/frdowd3/public_html/alex/alpha3/index.php on line 28 line 28 is -> header( 'Location: index.php?page=unlogged' );
  18. session_start(); include_once 'forms.php'; if($_GET['page']== null) { header( 'Location: index.php?page=main_page' ) ; } else if (file_exists(getcwd() .'/forms/' . $_GET['page'] . '.php')) {/*do nothing*/} else{header( 'Location: index.php?page=404' );} //everything went ok, up to here //as soon as I added the code below I started to get problems if ((isset($_SESSION['user_logged']) && $_SESSION['user_logged'] != "") || (isset($_SESSION['user_password']) && $_SESSION['user_password'] != "")) { //Do Nothing!} else { $index_page = strcmp($_GET['page'], "main_page"); $page_notfound = strcmp($_GET['page'], "404"); if($index_page == 0 || $page_notfound == 0) { //Do Nothing!} else { header( 'Location: index.php?page=unlogged' ); } } the code checks at first is the url that was give is correct, if not it is set to default page then the code checks if the url leads to an existent page or not, if the page does not exits, the code redirects to page 404 the part where I am started to get problems on is when I have checked if the user has been logged in or not. if logged in, do nothing if not logged in, then check if the user wants to go to main_page or page 404, if he is then do nothing, otherwise redirect to page where user needs to log in. the part that I have mentioned that checks for user sessions and so on, always tries to go to page call unlogged and then display the page cannot be found on the server, when the file is there. if I take out the buggy code then everything works and it can find all of the pages. how would I go about fixing the buggy code, there is just some minor logic error.
  19. nevermind, it works, had some ftp error if (file_exists('./scripts/' . $formName . '.php'))
  20. I would like to know how to validate included or required pages for their existence. something like this-> if(include_once['mypage']== nulll) { //do nothing } else { include_once['mypage']; }
  21. when I used "include" before it gave me a problem, so I started to use include_once
×
×
  • 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.