# Nic727

Members

195

0 Neutral

• Rank
Member
1. ## JAVA operator and result help

Nevermind, I just found out that I just needed to change the order of my else if and now it works. I changed in this order : if (g6 < 50) { g7 = 0; g8 = 0; } else if (g1 < 1){ g7 = 0; } else if (g1 >= 0){ g8 = 0; } else if (g7 > 0) { g8 = 0; } else if (g8 > 0) { g7 = 0; }
2. ## JAVA operator and result help

Hi, I'm making a weather app in Android studio using Java and XML for my school, and we need to use random number. The thing is that it doesn't work as expected. For example, I have some values here : g1 = r.nextInt((1 + 10) + 1) - 10; //Actual temperature g2 = r.nextInt((-10 + 15) + 1) - 15; //minimum g3 = r.nextInt((5 - 2) + 1) + 2; //maximum g4 = r.nextInt(40) + 1; //wind g5 = r.nextInt((11 - 3) + 1) + 3; //sun g6 = r.nextInt(100); //Precipitation g7 = r.nextInt((30 - 1) + 1) + 1; //rain g8 = r.nextInt((10 - 1) + 1) + 1; //snow //Here everything is good. But the problem is bellow. /***** RAIN / SNOW *****/ if (g6 < 50) { //if precipitation is less than 50%, make rain and snow at 0 g7 = 0; g8 = 0; } else if (g7 > 0) { //if it rain, make snow at 0 g8 = 0; } else if (g8 > 0) { //if it snow, make rain at 0 g7 = 0; } else if (g1 < 0){ //if temperature bellow 0 °C, make rain at 0 g7=0; } else if (g1 >= 0){ //if temperature above 0, make snow at 0 g8=0; } The thing is that I can have a 90% chance of rain, but it will be at 0... Or I can have -5 °C, but it will rain instead of snow. Any idea?

ok, but my label is for a button... When I click I have something like that : Better with image. It's happening after I click on the button.

sorry I explained badly. I was talking about when you click and not when you over the label. When I click on the button or label, the vertical bar is appearing on the label text. But I think I can't get rid of that with custom button... It's not doing this with default button (without label).

Thank you. I also changed .radio_label::before for .radio_label span:before ​Now the only problem is that when I click on the button, the vertical bar (for writing) is appearing on the label text... Can I get rid of that or have to live with it? Thank you

7. ## Can't use INSERT INTO

I forgot to add this little code at the bottom of my example : \$result=mysql_query(\$sql,\$con); but it's there and doesn't work.
8. ## Can't use INSERT INTO

I have a connection on top. Are you sure about variable in SQL, because with DELETE, UPDATE and SELECT it's working correctly.
9. ## Can't use INSERT INTO

Hi, I have a very weird problem, but I don't see where is my error. I have a form where it suppose to send the result into the data base, but Insert into doesn't work at all. <?php \$con = mysql_connect("localhost","root",""); mysql_select_db("databasename", \$con); mysql_query("SET NAMES 'utf8'"); if(!isset(\$_POST["envoyer"])){ ?> <form action="#action=completed" method="post"> <label for="nom">Nom de l'étudiant</label><br> <input type="text" id="nom" name="nom" value="" placeholder="Prénom et nom" maxlength="35"><br> <label for="num">Numéro de l'étudiant</label><br> <input type="text" id="num" name="num" value="" placeholder="#######" maxlength="7"><br> <label for="motpasse">Mot de passe</label><br> <input placeholder="ex:Chaise123" type="text" id="motpasse" name="motpasse" value="" maxlength="25"><br> <label for="motpasse2">Confirmer le mot de passe</label><br> <input placeholder="ex:Chaise123" type="text" id="motpasse2" name="motpasse2" value="" maxlength="25"><br> <label>Associer un milieu de stage</label><br> <select id="milieu" name="milieu"> <option value="">Ne pas associer tout de suite</option> <option value="" disabled="disabled">---Milieux de stage---</option> <?php \$sql = "SELECT * FROM employeurs"; \$result=mysql_query(\$sql,\$con); while(\$row = mysql_fetch_array(\$result)){ echo "<option value='".\$row['noemployeur']."'>".\$row['nomemployeur']." - ".\$row['nomcompagnie']."</option>"; } ?> </select><br> <label>Associer un superviseur</label><br> <select id="superviseur" name="superviseur"> <option value="">Ne pas associer tout de suite</option> <option value="" disabled="disabled">---Superviseurs---</option> <?php \$sql = "SELECT * FROM superviseurs"; \$result=mysql_query(\$sql,\$con); while(\$row = mysql_fetch_array(\$result)){ echo "<option value='".\$row['noemploye']."'>".\$row['nomemploye']."</option>"; } ?> </select><br> <input type="submit" id="envoyer" name="envoyer" value="Créer"><br> </form> <?php }else{ \$nom = \$_POST["nom"]; \$num = \$_POST["num"]; \$motpasse = \$_POST["motpasse2"]; \$emp = \$_POST["milieu"]; \$super = \$_POST["superviseur"]; \$sql = "INSERT INTO stagiaires (nometudiant, noetudiant, mdpetudiant)VALUES('\$nom', '\$num', '\$motpasse')"; \$sql = "INSERT INTO associations (noetudiant, noemployeur, noemploye)VALUES('\$num', '\$emp', '\$super')"; Any ideas? Don't know if it's because of Wamp or not, but it's very weird since it's working well manually into phpmyadmin with the online editor. Maybe it's how I wrote my variables, but I don't think it's that. I tried like : '\$num' '".\$num."' \$num ".\$num." But it's not working at all.
10. ## AJAX contact form not working

Thank you, it fixed it. Now I need to get it only send one email instead of two... Do you think it's because there is two mail() and need to put the first one into a variable? mail(\$destinataire,\$sujet,\$email_content,\$headers); // Send the email. if (mail(\$destinataire,\$sujet,\$email_content,\$headers)) { // Set a 200 (okay) response code. http_response_code(200); echo "Thank You! Your message has been sent."; } else { // Set a 500 (internal server error) response code. http_response_code(500); echo "Oops! Something went wrong and we couldn't send your message."; } EDIT : It worked
11. ## AJAX contact form not working

Also, is it a good idea to add this for form validation (PHP side) as an example : \$nom = htmlspecialchars(strip_tags(trim(\$_POST["nom"]))); So in my JS I could have the pattern and validation message showing on my page, but server side I could remove html code.... But still trying to figure what's wrong with http404... All my fields are not empty. Don't know why it think there is something wrong in my syntax?
12. ## AJAX contact form not working

Ok in my console I have : HTTP400: BAD REQUEST - The request could not be processed by the server due to invalid syntax. (XHR)POST - mywebsite.com
13. ## AJAX contact form not working

... Still not working. I did remove the first function and only put the variables here, but still go to contact.php with error "Oops! There was a problem with your submission. Please complete the form and try again." instead of staying on HTML page. Doesn't seem to get the AJAX working. EDIT : Nevermind, I just added the second faction into the first one. I can get the text appear on submit. GREAT! But still have the error... Maybe an error when checking if a field is empty? It doesn't seem like that... Also, why is it sending email two times if I remove this part?
14. ## AJAX contact form not working

Like what? Instead of : \$(function() { // Get the form. var form = \$('#ajax-contact'); // Get the messages div. var formMessages = \$('#form-messages'); // TODO: The rest of the code will go here... }); I should have​ // Get the form. var form = \$('#ajax-contact'); // Get the messages div. var formMessages = \$('#form-messages'); only?