Jump to content

brassfid

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

brassfid's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Well I feel like an idiot, I wasn't even running the .php, was mapped wrong in the action field in my .html form. Whoops. Thanks for the help though, it gave me a lot to think about!
  2. I did not know that about the forms. so that means that my error is in the .php not the .html. If I want it to return to the same page that it is submitted from (basically refresh the page) wouldn't I just put in the same url or would I want to actually make the button refresh?
  3. Been about a year since i played around with websites. My database is not being updated, and after submitting form it goes to the location of the action rather than running the action. Could someone please help! I am working in wordpress. Thanks the php form is <?php $con = mysql_connect("localhost","",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("", $con); $username = mysql_real_escape_string($_POST['username']); $betText = mysql_real_escape_string($_POST['betText']); $betMember1 = mysql_real_escape_string($_POST['betMember1']); //$sql adds bet to bet table $sql = "INSERT INTO betText (bettor, betText) VALUES ('$username', '$betText')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } $newBetID = mysql_insert_id(); $updatebetMember = "INSERT INTO betMember (betID, betMember) VALUES ('$newBetID','$betMember1')"; if (!mysql_query($updatebetMember,$con)) { die('Error: ' . mysql_error()); } mysql_close($con); header("Location:") ?> the form is <head> <script type="text/javascript"> function validateForm() { var x=document.forms["newbet"]["betText"].value if (x==null || x=="") { alert("You gotta have bet!"); return false; } var x=document.forms["newbet"]["betMember1"].value if (x==null || x=="") { alert("Who you betting against?"); return false; } } </script> </head> <form name="newbet" action="/wp-content/pbbbet.php" onsubmit="return validateForm()" method="post"> <label for="username"><strong>Username: </strong></label> <input id="username" name="username" type="text" readonly="readonly" value="<?php global $current_user; get_currentuserinfo(); echo $current_user->user_login; ?>"/> <strong>Peanut Butter Bet: <textarea cols="50" rows="4" name="betText"></textarea> <table width="75%" border="4"> <tr> <strong>Who is your bet against: </strong> </tr> <tr> <th> 1. </th> <th> <input name="betMember1" type="text" /> </th> </tr> </table> <script type="text/javascript"> function show_alert() { alert("Thank you!"); } </script> <input name="submitbet" input type="SUBMIT" onclick="show_alert()" value="SUBMIT" /> </form>
  4. Ahh, there is nothing being pushed out currently. I am using the script in a php document and then on the page itself I use: <?php include('/wp-content/aroma.php'); ?>
  5. Hello all, I found this dynamic checkbox list online. I have changed it to suit my needs, added some of my own parts but now, after getting past all the terminal errors, it now produces absolutely nothing. Can I get some help on why there is no echo occurring? Thanks! <?php function dynamic_checkbox_table ($sql_str, $col_label, $col_name, $val_checked, $cant_cols_tbl){ $sql_str = dynamic_checkbox_table("SELECT * FROM Categories"); $col_label = "catlevel3"; $col_name = "catlevel3"; $val_checked="S"; $cant_cols_tbl=3; //connect DB and run query $db="TB"; $db_user=""; $pass=""; $host="localhost"; @mysql_connect($host,$db_user,$pass); @mysql_select_db($db) or die ("cannot connect to DB"); $q_resultado = mysql_query($sql_str); mysql_close(); if (mysql_num_rows($q_resultado)==0) exit("no rows returned"); $next_row = mysql_fetch_array($q_resultado); //fetch first row $output = "<table border=\"1\">\n"; //open table tag do { $output .= "<tr>\n"; //open row tag for ($i=1 ; $i <= $cant_cols_tbl ; $i++ ){ //loops as many times as $cant_cols_tbl $row=$next_row; $output .= "<td>"; //open TD tag $output .= (!$row) ? "" : '<input type="checkbox" name="'.$row[$col_name].'" value="'.$val_checked.'" />'.$row[$col_label]; echo (!$row) ? "" : '<input type="checkbox" name="'.$row[$col_name].'" value="'.$row[$val_checked].'" />'.$row[$col_label]; $next_row = mysql_fetch_array($q_resultado); //retrieve next row $output .= "</td>\n"; //close TD } //close for loop $output .= "</tr>\n"; //close row } while ($next_row); //close do-while (and checks if there's another row) $output .= "</table>\n"; //close table return $output; } ?>
×
×
  • 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.