PHP - Moved: Check Which Button Was Clicked In Html Form Using Php....help.
This topic has been moved to JavaScript Help.
http://www.phpfreaks.com/forums/index.php?topic=331164.0 Similar TutorialsThis topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=317810.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=327134.0 This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=347219.0 Hi Everyone, I am having problems when submitting a form that has check boxes within it (post.php). All the check boxes have a name and a checked value of 1 - the receiving page (for example submit.php) has the variables defined: $tickbox1 = $_POST['tickbox1']; The problem I am finding is that if the box isnt checked - I get an "index is not defined" error. I would suppose because there is no value. I have tried this before and it has worked, however that was on Apache and this is on IIS. Is there a work around? Thanks Matt This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=356816.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=350095.0 This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=307745.0 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=332103.0 I have a comment section. It is comprised of 3 major files. One file creates the form where you fill in your name and comment. Another file sends your comment to the DB. The third file displays the already existing comments on the page. You have the option to reply to the existing comments on the page. When you click the reply button I would like the comment text box to light up so the user knows its working but I have hit a brick wall.
This is the comment form the user actually types into:
<div id="comment-container" > <form id="comment_form" action="/comm_1/post_comment.php" method='post' onsubmit=" return validateForm()"> <table> <tr> <td id="error"></td> </tr> <tr> <td><textarea name="comment_body" id='comment_body' placeholder="Comment"></textarea></td> </tr> <?php if(!$username && !$userid): ?> <tr> <td><input type="text" name="name" class="input_style" placeholder="Name"/> <input type="submit" id="loginbtn" value="Or Login" onclick="window.location='/login_scripts/login.php'" /></td> </tr> <tr> <td><input type="email" name="email" class="input_style" placeholder="Email"/></td> </tr> <?php endif; ?> <?php if($username && $userid): ?> <input type="hidden" name="name" value="<?php echo htmlspecialchars($username) ?>"/> <input type="hidden" name="email" value="<?php echo htmlspecialchars($email) ?>"/> <?php endif; ?> <tr> <input type='hidden' name='parent_id' id='parent_id' value='0'/> <td><input type="submit" name="submitbtn" id="submitbtn" value="Add comment"/></td> </tr> </table> </form>This how the existing comments are displayed on the page: You can see on line 7 is the button to the reply to a comment. When this is clicked I need the "comment_body" from the above code to highlight. <?php function getComments($row) { echo "<li class='comment'>"; echo "<div class='aut'>".$row['author']."</div>"; echo "<div class='timestamp'>".$row['created_at']."</div>"; echo "<div class='comment-body'>".$row['comment']."</div>"; echo "<a href='#comment_form' name='replybtn' class='reply' id='".$row['id']."'>Reply</a></script>"; $q = "SELECT * FROM threaded_comments WHERE parent_id = ".$row['id'].""; $r = mysql_query($q); echo "</li>"; if(mysql_num_rows($r)>0) { echo "<ul>"; while($row = mysql_fetch_assoc($r)) { getComments($row); } echo "</ul>"; } } ?>I tried this with JS, but it does not work: $(function(){ $("a.reply").click(function() { var id = $(this).attr("id"); $("#parent_id").attr("value", id); $("#comment_body").focus(); }); }); Edited by ryanmetzler3, 26 January 2015 - 09:48 PM. Hello - I need a way to execute a stored procedure from a wordpress site with an external database where the stored procedure is housed. I am very limited in php code. All I know is from what little I have used My Custom Functions plugin. Please be very detailed. This stored procedure I run truncates and re-populates a number of tables I use for various reports. I am pulling data from the wp db and creating tables in the external db which make the data easier to read than through the wp meta data. The tables are housed in a separate db so as not to slow down the wp db. The hosting company does not allow 'Events' to run on the mySql db so I am left with figuring out how to create a cron job using a php file which would be the best. Aside from that, I thought a button on an admin page for execution would make it easier if I have to do it be hand. Thanks for your help. Hi, I am new to PHP world!! I am just trying to find a way to disable a button after its been clicked for lets say 5 minutes. I have searched google and haven't found what I am looking for. I just dont want the users to be able to refresh the page and the button becomes enabled again. any code examples with explanation or a simple tutorial will be much appreciated. Thanks This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=343133.0 This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=317537.0 I feel like a moron asking this question as it seems to be one of the most common things done with php but I cannot find a tutorial (probably because I don't know the correct wording to search under) on this specific thing.. Anyhow. I'm spitting out a list of the Titles of my test table like so (and its working as expected): <?php $posting_sql = "SELECT * FROM postings"; $posting_results = (mysqli_query($cxn, $posting_sql)) or die("Was not able to grab the Postings!"); while($posting_row = mysqli_fetch_array($posting_results)) { echo "<li><a href='posting_details.php'>$posting_row[title]</a></li>"; } ?> Now as you can see: <a href='posting_details.php'> I am calling a new page, and that page contains this: <h2><?php echo "$posting_row[title]"; ?></h2> <p><?php echo "$posting_row[description]"; ?></p> It's no surprise it's not working (with many variations etc), but I am only familiar with using <form> GET or POST, and these of course are not form elements, so I cant seem to call them the same way. My suspicion (and from the research data I could find) is that I need to pass values in my link: <a href='posting_details.php'> ... I could not get it to work, but I was trying variations like: <a href='posting_details.php?get[title&get[description]]'> but it seems like I am screwing things up even more by doing this.. Anyhow. If anyone could show me a tutorial that covers this specifically or some suggestions on the best approach to this would be much appreciated.. This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=348155.0 I'm currently creating a web based application for the company I'm working on. It was just a simple application that I can surely done but there is one thing that become a hindrance... That thing is the situation wherein dialog box that keeps on popping whenever I clicked the submit button wherein supposed to be it should change page. Hope everyone could help. Thank you in advance. Hi there, I've been tasked with the job of re-doing the company website from scratch and I'm having a bit of trouble with some of the logic involved as I'm not a web designer by trade. Or by any reasonable stretch of the imagination. Anywhoot, what I'm struggling with is this: I have laid out the website so for each of the core business units there is one php page, call it 'page x'. On page x there are two sections; a sidebar and a content section. At the top of page x there is a menu bar with a links to a different category (eg. services, products, about, contacts, etc). What I have at the moment for page x is an INCLUDE statement in each of the subsection which pulls through a html page and plops it down in the right place. What I am struggling with is how to use the links at the top of the page to pull through a different html page depending on what link I click. I was thinking that I could use something a couple of variables, $sidebar and $content, and then some kind of on-click function to pass a string to each of the variables and then use the INCLUDE statement to call the correct pages. What I have tentatively come up with is this : Code: [Select] <a href=#><img src="/MS_Images/service_hlight.jpg" width="100" height="42" onclick=$sidebar = "OutsourceIT_Website/Managed Services/services_side.html" /></a> and then: Code: [Select] <?php include $sidebar; ?> Would this work in principle? How do I go about making sure that the variable in the link is declared properly? Is there a better way to go about doing this that I am missing due to my ignorance? Hope someone can help because Uncle Google is getting fed up with my vague search terms. Hi Everyone, can you pls try to find out why this is not working <?php if(isset($_REQUEST['btn'])) { echo "working"; } ?> <html> <body> <input type='Button' name='btn' id='btn' value='Button'> </body> </html> Hi there once again, sry for previous wrong section, i guess this time i'm on the right place ;p Well i need following: I have few forms (input fields) with requested informations, also i have other .php file which i'm calling to send a form. Now i need to know how can i do a check for those fields if they are empty or not. If they are, i need to STOP submiting the form (calling the other .php). Codes: Form: Code: [Select] <form name="f1" form method="post" action="posalji.php"/>Field: Code: [Select] <input type="text" name="hp1" size="20"/>Submit: Code: [Select] <input name="f1" type="image" src="registruj.png" onclick="if(f1.hp1.value.length==0) alert('Error: field can't be empty'); else f1.submit(); if(f1.hp2.value.length==0) alert('Error: field can't be empty'); else f1.submit();"/>There are more than one field, that's why you can see more errors in submit. Well all i need is "die" or "stop" calling the "posalji.php" from action above. Sry 4 poor english. Code: [Select] <?php $db = mysql_connect("localhost", "root") or die("Could not connect."); //username and password if(!$db) die("no db"); if(!mysql_select_db("simple",$db)){ if(!mysql_select_db("regis",$db)){//database name die("No database selected.");}} $message=$_POST['message']; print "<form action='registration.php' method='post'onsubmit='return msg();'>"; print "Your message:<br>"; print "<textarea name='message' cols='40' rows='2'></textarea><br>"; print "<a onClick=\"addSmiley(':)')\"><img src='smile.gif'></a> "; print "<a onClick=\"addSmiley(':(')\"><img src='blush.gif'></a> "; print "<a onClick=\"addSmiley(';)')\"><img src='images/wink.gif'></a> "; print "<input type='submit' name='submit' value='Set Name'></form>"; print "<script language=\"Java Script\" type=\"text/javascript\">\n"; print "function addSmiley(a)\n"; print "{\n"; print "document.form.message.value += a;"; print "document.form.message.focus();\n"; print "}\n"; print "</script>\n"; print "<br><br>"; ?> <script type="text/javascript"> <?php function msg(){ if(isset($_POST['submit'])) //if submit button push has been detected { if(strlen($message)<1) { // print "You did not input a message"; echo"<SCRIPT LANGUAGE='javascript'>alert('You did not input a message')</SCRIPT>"; } else { $message=strip_tags($message); $IP=$_SERVER["REMOTE_ADDR"]; //grabs poster's IP $checkforbanned="SELECT IP from admin where IP='$IP'"; $checkforbanned2=mysql_query($checkforbanned) or die("Could not check for banned IPS"); if(mysql_num_rows($checkforbanned2)>0) //IP is in the banned list { print "You IP is banned from posting."; } else if(strlen($message)>=1) { $message=strip_tags($message); echo("<SCRIPT LANGUAGE='JavaScript'>window.alert('$message')</SCRIPT>"); // die("<meta http-equiv=\"refresh\" content=\"0; url=registration.php\">"); } $message=$_POST['message']; $message=strip_tags($message); /* if($_POST['username'] && $_POST['pass']) { $name = mysql_query("SELECT * FROM Persons"); $thedate = date("U"); //grab date and time of the post $insertmessage="INSERT into mesej (name,IP,postime,message) values('$name','$IP','$thedate','$message')"; mysql_query($insertmessage) or die("Could not insert message"); } */ } } return false; } return true; </script> ?> This is my code in my submit2.php im clicked submit button but if it is empty it should return an javascript alert error but why it directs through registration.php without reading the rules? |