
WeBBy421
Members-
Posts
16 -
Joined
-
Last visited
WeBBy421's Achievements

Member (2/5)
0
Reputation
-
(empty) does not work because there is more to the code than what I showed. Didn't show entire code because thew first half fails on its own. Here is the full code that words: <li class="li-btn"> <a class="custom-btn custom-btn--small custom-btn--style-4" <? if ($user == ""){ echo "href=\"https://www.example.com/login.php\">Member Login</a>"; } elseif ($user != ""){ echo "href=\"https://www.example.com/mycp.php\">$user</a>"; } ?> > </li> That above works but throws the Undefined variable warning; If I use: if(isset($user) && $user == ''){ echo "href=\"https://www.example.com/login.php\">Member Login</a>"; The page is completely destroyed because $user is not recognized or something and the <a class is not closed: <a class="custom-btn custom-btn--small custom-btn--style-4" </li> WHY?
-
Have the following code that works just fine but throws a Undefined variable warning: <a class="custom-btn custom-btn--small custom-btn--style-4" <? if ($user == ""){ echo "href=\"https://www.paratuberculosis.com/login.php\">Member Login</a>>"; } If I try to use: <? if(isset($user) && $user == ''){ It does not work. In other words I get nothing and the ">" doesn't print and the entire page messed up. It's like $user is not seen by isset?? Any thoughts would be appreciated
-
Not all quieries from form checkboxes are not being executed
WeBBy421 replied to WeBBy421's topic in PHP Coding Help
I thought I submitted my code before I headed out to work, but apparently I never hit the submit button. Because it is really irrelevant at this point, I did not mean to submit but I guess I did. That being said, thank you all for some GREAT ADVICE. Thank you mac_gyver AND Psycho, you have given me multiple solutions. Much appreciated -
Not all quieries from form checkboxes are not being executed
WeBBy421 replied to WeBBy421's topic in PHP Coding Help
<form action="" method="post" name="election" id="election"> <? $db = mysqli_connect($db_hostname,$db_username,$db_password,"ptb_members") or die ("Cannot connect to MySQL"); $result = mysqli_query($db,"SELECT * FROM NewBoard"); while ($row = mysqli_fetch_array($result)) { extract($row); echo "<div class=\"flex-container\"> <div> <input type=\"checkbox\" name=\"vote\" value=\"$lname\"> - $fname $lname <br><hr><br> <div style=\"text-align:center\">$country</div> </div> <div> <img src=\"./images/$photo\" alt=\"$fname $lname\" style=\"width:100%;max-width:200px;\"> </div> <div class=\"valign\"> <a href=\"$url\">Personal Profile & Statement</a> </div> </div> <br>"; } ?> <div style="text-align:center;"> <br> <input type="submit" name="submit" value="Vote" class="formbutton"> </div> </form> -
I have a form with several (9) checkboxes that are part of a association vote. The user can vote (select) up to 4 checkboxes of which the results (votes) are then recorded in database. The form is processed as: if ($_POST['vote'] == 'Juste'){ $result = mysqli_query($db,"UPDATE NewBoard SET votes=votes+'1' WHERE lname = 'Juste'")or die ("Fatal Query Error: " . mysqli_error($db)); } if ($_POST['vote'] == 'Chavez-Gris'){ $result = mysqli_query($db,"UPDATE NewBoard SET votes=votes+'1' WHERE lname = 'Chavez-Gris'")or die ("Fatal Query Error: " . mysqli_error($db)); } etc (for all 9 entries) My problem is that only the last checked box gets recorded. If I check both the checkboxes above (both if statements would be true), only the Chavez-Gris is recorded. Need all checked checkboxes recorded not just the last one. Any help and wisdom would be greatly appreciated. Thanx
-
Trying to run a mysqli query inside another query and don't get past a single cycle. What wrong - I am a n00bie! $result = mysqli_query($db,"SELECT * FROM test WHERE active = 'y' AND expiredate < $todaydate") or die("<b>Error in Query</b>.\n<br>Error: " . mysqli_error($db)); while ($row = mysqli_fetch_array($result)) { extract($row); $query = "UPDATE test SET active='t' WHERE (id = '$id')"; $result = mysqli_query($db,$query) or die("<b>Error in Query 3</b>.\n<br>Error: " . mysqli_error($db)); echo "$fname $lname ($id) active status changed to n <br>"; unset($fname, $lname, $email, $id, $expiredate); } Gives me an error on the while statement (line 2) on second cycle. ???
-
THIS IS RIDICULOUS !!! I had found the issue with allow_url_fopen in another post. And checked that it was on and it was. /$ grep allow_url_fopen /usr/local/lib/php.ini allow_url_fopen = On Rather than ssh, decided to turn on php error reporting through cpanel WHM and in the Multiphp ini editor it said allow_url_fopen DISABLED !!! WTF !! Enabled and all working - dont want to even think of the hours wasted on this. Why ssh says ON and cpanel says OFF ???
-
I do not get it. The only thing that has changed is an upgrade to php 7.3 from 5.6. I cannot believe this is the problem. But only thing that has changed Your code gives the same result "You're not a human!": <html> <head> <title>Captcha Test</title> <script src="https://www.google.com/recaptcha/api.js" async defer></script> </head> <body> <? $siteKey = 'xxxx'; $secretKey = 'xxxx'; ?> <form action="" method="POST"> <div class="g-recaptcha" data-sitekey="<? echo $siteKey; ?>"></div> <br/> <input type="submit" name="submit" value="Submit"> </form> <? if(isset($_POST['submit'])) { /* The Following to get response back from Google recaptcha */ $url = "https://www.google.com/recaptcha/api/siteverify"; $remoteServer = filter_input(INPUT_SERVER, 'REMOTE_ADDR', FILTER_SANITIZE_URL); $response = file_get_contents($url . "?secret=" . $secretKey . "&response=" . \htmlspecialchars($_POST['g-recaptcha-response']) . "&remoteip=" . $remoteServer); $recaptcha_data = json_decode($response); /* The actual check of the recaptcha */ if (isset($recaptcha_data->success) && $recaptcha_data->success === TRUE) { $success = "Mail was sent!"; $data['name'] = filter_input(INPUT_POST, 'name', FILTER_SANITIZE_FULL_SPECIAL_CHARS); $data['email'] = filter_input(INPUT_POST, 'email', FILTER_SANITIZE_EMAIL); $data['phone'] = filter_input(INPUT_POST, 'phone', FILTER_SANITIZE_FULL_SPECIAL_CHARS); $data['website'] = filter_input(INPUT_POST, 'website', FILTER_SANITIZE_FULL_SPECIAL_CHARS); $data['reason'] = filter_input(INPUT_POST, 'reason', FILTER_SANITIZE_FULL_SPECIAL_CHARS); $data['comments'] = filter_input(INPUT_POST, 'comments', FILTER_SANITIZE_FULL_SPECIAL_CHARS); $send = new Email($data); echo "Send Email"; } else { $success = "You're not a human!"; // Not on a production server: echo $success; } } ?> </body> </html> Nothing makes sense (to me anyway)....
-
I am beginning to think it is related to a php 7.3 upgrade? Can anyone verify this or not?
-
I do not find any errors. Based on the Google dashboard it states "We detected that your site is not verifying reCAPTCHA solutions.". Also shows that they appear to have been working on 2/25 with several passed but "no Captchas" on 2/28. How do I log the $response?
-
I have been running Google ReCaptcha v2 on 4 different sites for a very long time without any problem. They were all working fine. Not sure when as I was just recently made aware it, but none of them work anymore ??? Did google change something or is it because I updated php?? The problem is in the response - no matter what I try, I cannot verify that I am human. This is the response code: if(isset($_POST['g-recaptcha-response'])){ $captcha=$_POST['g-recaptcha-response']; } if(!$captcha){ include ('./forms/sectionhead.tpl'); echo '<h4 style="color:#c30000;text-align:center;">You must check the reCaptcha form to send this email.</h4>'; include ('./forms/contactform.php'); include ('./forms/contactend.php'); exit; } $ip = $_SERVER['REMOTE_ADDR']; $response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secretKey."&response=".$captcha."&remoteip=".$ip); $responseKeys = json_decode($response,true); if(intval($responseKeys["success"]) !== 1) { echo '<h4 style="color:#c30000;text-align:center;">Sorry, we cannot verify that you are human</h4><br><br>'; } else { //send email [\code] For some reason I am no longer getting a successful response. Any help would be greatly appreciated Thanx
-
mysqli_fetch_array() expects parameter 1 to be mysqli_result
WeBBy421 replied to WeBBy421's topic in PHP Coding Help
Just as a foillow-up... Am using the exact same parameters after the above query to send emails to all those in databse with exempt="n" without any errors (for reasons I cannot go into cannot combine the scripts). So, I am still unsure why thsi one goes into error but the one that follows does not. The structure of the column being changed is enum('y', 'n'). Adding $db to the mysqli_error() does not increase error info. Also, no error if no db changes made Thanx again -
mysqli_fetch_array() expects parameter 1 to be mysqli_result
WeBBy421 replied to WeBBy421's topic in PHP Coding Help
Thanx that answers a few questions, but maybe it is my N00bie status, but these answers realy do not tell me how to fix the error -
Don't understand why I am getting this error: Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /home/paratb/public_html/admin/cron/duesreminder.php on line 8 Here is the script: 1 require_once ('../connect.php'); 2 $todaydate = $_SERVER['REQUEST_TIME']; //current timestamp 3 $db = mysqli_connect($db_hostname,$db_username,$db_password,"paratb_members") or die ("Cannot Connect to database"); 4 $result = mysqli_query($db,"SELECT * FROM members WHERE active = 'y' && exempt = 'n'") or die (mysqli_error()); 5 while ($row = mysqli_fetch_array($result)) { 6 extract($row); 7 if ($expiredate < $todaydate){ 8 $query = "UPDATE members SET active='n' WHERE (id = '$id')"; 9 $result = mysqli_query($db,$query) or die (mysqli_error()); ; 10 echo "User $fname $lname ($id) active status changed to n<br>"; 11 unset($id); 12 } 13 } The script actually does what it is supposed to but throws the error after every change it makes. NO mysqli error is defined. Funny thing is that if I comment out line 9, it cycles through without error so it is definately the successful query that causes the error? Any suggestions
-
Email sending to many headers I am sending out an email but it contains a repeat of some of the headers. It gets rejected from some servers as having >128 recipients or excessively long headers. Since it is only sending to one recipient at a time, the 128 must refer to the headers. Example: Reply-To: Webite Name <[email protected]>, Webite Name Repeated too many times to count X-Mailer: PHP/5.4.45From: Webite Name <[email protected]> Also repeated too many times to count Below is my script: if ($todaydate > $almostdue){ $to2 = "$fname $lname <$email>"; $subject2 = "Your Membership Dues are Expiring"; $headers2 .= "From: Website Name <[email protected]>" . "\r\n"; $headers2 .= "Reply-To: Website Name <[email protected]>" . "\r\n"; $headers2 .= "MIME-Version: 1.0" . "\r\n"; $headers2 .= "Content-type:text/html;charset=UTF-8" . "\r\n"; $headers2 .= 'X-Mailer: PHP/' . phpversion(); $fromEmail = "[email protected]"; $fifth = "-f" . $fromEmail; $message2 = "<div style='font-family:arial;font-size:14px;'> Dear $fname,<br><br>blah, blah,blah</div><br><br>"; mail($to2, $subject2, $message2, $headers2, $fifth); Any help in why this is happening would be greatly appreciated Why can't I paste anything here? So, had to paste everything as code...