Jump to content


  • Posts

  • Joined

  • Last visited

michaelfurey's Achievements


Member (2/5)



  1. I created a login system with bootstrap but for some reason I cannot delete the "placeholder" (in which it is written "admin") in both the inputs of the form ("uname" and "psw"). Even if I change the placeholder it's remain "admin". Have you any idea? This is the code: <!DOCTYPE html> <html> <head> <title>Login</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script> <link rel="stylesheet" type="text/css" href="css/styles.css"> </head> <body> <div class="container"> <div class="jumbotron text-center" id="jumbo_log"> <h1>Login Page</h1> <p>You must login to enter</p> <form id="theform" method="get"> <div class="container2"> <label for="uname"><b>Username</b></label> <input type="text" id= "uname" name="uname" required><br> <label for="psw"><b>Password</b></label> <input type="password" id="psw" name="psw" required><br><br> <input type="submit" id="submit" class="btn btn-info" value="Login"><br><br> <a class="btn btn-primary" href="registration.php" role="button">Click here if you are not registered</a> </div> </form> </div> </body> </html>
  2. Uhm I tried changing the method (post) but nothing change. In the image what happened. The status is canceled. When I insert that line the status is canceled furthermore the alert and the redirect don't work, even if the insert works well with the DB MySQL.
  3. I have created a registration page to access my website. After the user registrate himself should appear an alert saying that the registration was OK and a redirect to main.php page... however for some reason if I create an insert statement the alert and the redirect don't appear... If I remove the insert the alert and the redirect works... why? This is part of the code of my 3 files: registration.php (ajax call) $('#submit').click(function() { var username2 = $('#uname2').val(); var password2 = $('#psw2').val(); $.ajax({ url: 'ajax/response.php', type: 'GET', data: {username2 : username2, password2: password2}, success: function(data) { if(data === 'correct') { alert("Username and Password have been created!"); //don' work with the insert location.replace("main.php"); //don' work with the insert } else { alert("Username or password are not correct... please register yourself!"); } } }); }); response.php (answer to ajax call) if(isset($_GET['username2']) && isset($_GET['password2'])) { $username2 = $_GET['username2']; $password2 = $_GET['password2']; if (checkUser($pdo, $username2) === true) { echo 'duplicate'; } else { insertUserPwd($pdo, $username2, $password2); //including this line the redirect and the alert doesn't work... the insert is OK echo 'correct'; } } data_access.php (the function works but doesn't permit alert and redirect to appear) function insertUserPwd(PDO $pdo, $usr, $pwd) { $data = [ 'id' => '', 'user' => $usr, 'password' => $pwd ]; $sql = "INSERT INTO users (id, user, password) VALUES (:id, :user, :password)"; $stmt= $pdo->prepare($sql); $stmt->execute($data); } Can someone help me to fix the code?
  4. Uhm yes the row in the second line is useless because I forgot to delete it. Yep probably I will follow your instructions because I don't want to use JS/Ajax step!
  5. This is my PHP code: echo "<table>";form($current_php); $cit=do_order("select * from country_itemize_types"); echo "<tr><td>Description: </td><td><select name='descr_ger' id='descr_ger'>"; $descr_sql=do_order("select distinct description from country_itemize_types"); while ($descr_arr=mysql_fetch_array($descr_sql)){ echo "<option>" . $descr_arr['description'] . "</option>"; } echo "</select></td></tr></table>"; And this is my mysql table named country_itemize_types (the table has thousand rows but I pasted here only few lines...): +-----+------+--------------+---------+------------+----------+----------+------------------+ | uid | type | description | country | field | priority | datatype | option | +-----+------+--------------+---------+------------+----------+----------+------------------+ | 1 | 12 | travelcost | ger | vehicle | 1 | char | car;bus;airplane | | 2 | 12 | travelcost | ger | distance | 2 | decimal | | | 3 | 12 | travelcost | ger | times | 3 | integer | | | 4 | 12 | travelcost | ger | cost | 4 | decimal | | | 5 | 12 | randomcost | ger | earthquake | 1 | char | weak;strong | | 6 | 12 | randomcost | ger | seaquake | 2 | char | weak;strong | | 7 | 12 | randomcost | ger | cost | 3 | decimal | | | 8 | 12 | marriagecost | ger | times | 1 | integer | | +-----+------+--------------+---------+------------+----------+----------+------------------+ I would like to create a select tag containing all the descriptions of the table (see the php code above) and when the user selects an option on this select tag should appear some input tag. For example if the user selects from the dropdown menu "travelcost" should appear 4 new input tags (vehicle, distance, times, cost). If the user selects "marriagecost" should appear only one new input tag (times). How can I do that? I suppose that I have to run a sql query with javascript or something similar but I am a newbie in javascript...
  6. Is it possible to download the output of the previous code from the server to the client? In that way I should obtain the xml content in the client without copying and paste through the browser. In other words I would like to run a file located in the server that generates the xml file and to download it authomatically to the client.
  7. Ok perfect that I wanted to know! I apreciated also the test that you created for me to check if I have some problem solving skills ( " htmlsCpecialchars($xml) " ).
  8. I have to generate the following text with a php script in the server and render it in chrome, then copy it manually with the mouse and finally paste it manually in a xml file located in my desktop pc. The text is the following: <?xml version="1.0" encoding="UTF-8"?> <shiporder orderid="889923" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="shiporder.xsd"> <orderperson>John Smith</orderperson> <item> <title>Hide your heart</title> <quantity>1</quantity> <price>9.90</price> </item> <item> <title>Hide your heart</title> <quantity>1</quantity> <price>9.90</price> </item> </shiporder> The problem is that I have to render in the browser also the tags and the text included inside the tags... is it possible to render that text in chrome in that way?
  9. Ok perfect solved! function switchDay (dateInput) { var date = dateInput.value; var dayF = new Date(date); var dayNumber = dayF.getDay(); switch (dayNumber) { case 0: day = "Sunday"; break; case 1: day = "Monday"; break; case 2: day = "Tuesday"; break; case 3: day = "Wednesday"; break; case 4: day = "Thursday"; break; case 5: day = "Friday"; break; case 6: day = "Saturday"; } return day; } document.querySelector("input[name='date']").addEventListener('change', function(e) { var dateInput = e.target; day = switchDay(dateInput); $('input[name=day]').val(day); });
  10. I have a php file and in javascript I am a newbie. This is my php code: echo 'Date:<input type="date" name="date">'; echo 'Day:<input type="text" name="day">'; I would like that when the user select a date from the input "date" in the input "day" appears the right day. For example if the user writes "18/07/2017" in the input "date", in the second input tag should appear "Tuesday". Is it possible to do that?
  11. Uhm I will try to install it... then I will give you a feedback!
  12. I downloaded and install php 7 and apache 2.4 on windows 10 but it didn't work. Probably Apache gave me problems. Do you know other ways to run PHP on windows 10? Maybe Apache wasn't the best solution?
  13. Starting from a PHP script I would like to select some options of a multiple select... but I don't know how. This is my html code: <select id="pairlang[]" name="pairlang[]" multiple size=3> <option value="volvo">Volvo</option> <option value="saab">Saab</option> <option value="mercedes">Mercedes</option> <option value="audi">Audi</option> </select> <input type="submit" value="save allllll" name="update" class="great" onclick="pairSave()"> This is my js code: function pairSave() { var newJs = <?php echo json_encode($pair); ?>; alert(newJs); } The output of the alert is an array: volvo,saab Someone knows how to select the options volvo and saab with the function pairSave?
  14. This is my code: <script type="text/javascript"> $(document).ready(function() { $(".js-example-basic-single").select2(); }); </script> <select class="js-example-basic-single"> <option value="volvo">Volvo</option> <option value="saab">Saab</option> <option value="opel">Opel</option> <option value="audi">Audi</option> <option value="fiat">Fiat</option> <option value="mercedes">Mercedes</option> <option value="bmw">BMW</option> <option value="tata">Tata</option> </select> Unfortunately I am using Select2 that is a plugin of jquery... I have the impression that the attribute size doesn't work with it.
  15. I would like to create a select that shows immediately some option values without waiting that the user clicks on the arrow in order to see the option values... is it possible?
  • 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.