Jump to content

Adam Brave

Members
  • Content Count

    25
  • Joined

  • Last visited

Everything posted by Adam Brave

  1. I have a form defined by the following code: <form name="input" action="insert.php" method="get"> <input type="text" name="meeting"><input type="Submit" value="Gravar"></form> And, in other file (insert.php), I want to insert in the database the information that the user introduced onto the form with the following code: <?php session_start(); ?><html><body><?php $link = mysqli_connect('localhost', 'root');if (!$link) { die('Nao foi possivel conectar: ' . mysqli_error()); }else{echo 'Conexao bem sucedida';echo "<br />";}mysqli_select_db("databasexpto", $link); $appoint = mysqli_query("INSERT INTO appointments (`what`, `owner`) VALUES('$_POST['meeting']','$_SESSION['userID']')"); if (!mysqli_query($link,$sql)) {die('Error: ' . mysqli_error());}else{ echo "1 record added";} mysqli_close($link);?></body></html> When I execute the code I receive the following error: Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:\Program Files\EasyPHP-12.1\www\files\insert.php on line 21 Can someone help me?
  2. That works in javascript but not in php. I want a instruction that works inside of the tags <?php ... ?>
  3. Solved $result = mysql_query(SELECT * FROM userdb WHERE mail LIKE '$maill' AND pass LIKE '$passwordd'); Btw, can someone tell me how do I load a html page with php code? In javascript I would use the instruction location.href but how do I load a page with php?
  4. Well I was in fact trying to use an access database LOL that may be the problem.I wil try to change to a sql database then
  5. I have changed the code to this: $maill = $_POST['fmail'];$passwordd = $_POST['fpass'];$mysqli = new mysqli("localhost",$maill,"");/* check connection */if ($mysqli->connect_errno) { printf("Connect failed: %s\n", $mysqli->connect_error); exit();}$mysqli->select_db("database.accdb");$result = $mysqli->query("SELECT * FROM user WHERE mail=$maill AND password=$passwordd");$row = $result->fetch_row();printf("Default database is %s.\n", $row[0]); And my output is: "Fatal error: Call to a member function fetch_row() on a non-object in C:\Program Files\EasyPHP-12.1\www\welcome.php on line 27" Line 27 : $row = $result->fetch_row(); Now, I'm sure that I have a row in my database with the mail and password stored on the variables $maill and $password and, I'm also sure, that these variables have the corresponding information so why can't I validate that user?
  6. From what I see, the information submitted by the user (mail=asd@hotmail.com and password=asd) have something wrongon the password. For example I printed the two variables and get this: <form action="welcome.php" method="post">mail: <input type="text" name="fmail">password: <input type="text" name="fpass"><input type="submit"></form>...$maill = $_POST['fmail'];$passwordd = $_POST['fpass'];echo $maill;echo "<br>";echo $passwordd; Output:asd@hotmail.comasdbool(false) From where come the "bool(false)" ?
  7. Hi, I want to make a login and a validation in a database. In order to do it I use the following code where: user -> table with all the user information like birthday, mail, username, first name etcpassword -> column of the table "user" that contains all the passwordsmail -> column of the table "user" that contains all the mails. The two variables, $maill and $passwordd, are use to store the information required at the login moment to the user. $result = mysql_query("SELECT password FROM user WHERE mail=$maill");$row = mysql_fetch_array($result); if ( $row['mail'] == $maill && $row['password'] == $passwordd ){ echo $row['name'] . " " . $row['ultimonome']; } else { echo "login not correct"; } Output: Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\Program Files\EasyPHP-12.1\www\welcome.php on line 29login not correct Can someone help me?
  8. Just one last question a little bit offtopic. I have this two lines of code: month = document.calForm.selMonth.options[document.calForm.selMonth.selectedIndex].value;month += 1; What I expected that should happen was the variable "month" to be incremented, but what really happen is that if "month" is equal 5 on the end of the first line then in the second line it will result "51" . The instruction "month += 1" does not do a numerical calculation, instead, it joins "1" to the previous value of the variable. How can I change this?
  9. Solved: myJSON = '{ "jday" : "' + day + '", "jmonth" : "' + month + '", "jyear" : "' + year + '" }'; Tkz for the help
  10. Well it works with just the jday but when I do this on the first file: myJSON = { "jday" : "' + day + '", "jmonth" : "' + month + '", "jyear" : "' + year + '"}; I can't see none of the three elements
  11. But with the true parameter what I get is: " array(1) { ["jday"]=> string(2) "24" } "
  12. With the decode: <?php$dayphp = $_GET['xpto'];$obj = json_decode($dayphp);echo $dayphp;?> My output is: "object(stdClass)#1 (1) { ["jday"]=> string(2) "24" } " =\
  13. I put here just the "day" element to simplify and get some result but in the end what I want to pass is something like that: myJSON = { "jday" : "' + day + '", "jmonth" : "' + month + '", "jyear" : "' + year + '"};
  14. With this: function NewPage(day){myJSON = '{"jday":"' + day + '"}';location.href = 'new.php?xpto=' + encodeURIComponent(myJSON);}....<?php$dayphp = $_GET['xpto'];var_dump($dayphp);?> My output is: " string(13) "{"jday":"24"}" ,, " But I just want the number 24. How do I get rid of the rest? Tkz for the help guys
  15. Well..here is what I have done. On the first file I have: text += "<td align=center><span id=sp" + aa + " onClick='NewPage(" + aa + ")'></span> </td>";...function NewPage(day){myJSON = { "jday" : day}; // I'm trying to pass the function argument (day) to the "jday" field.location.href = 'new.php?xpto=' + myJSON;} On the second file I have: <?php$dayphp = $_GET[xpto];echo $dayphp;?> My output is: "Notice: Use of undefined constant xpto - assumed 'xpto' in C:\Program Files\EasyPHP-12.1\www\new.php on line 13[object Object] ,, " Help..lol
  16. Hmm ok, I wil use the JSON object but from what I see I dont understand how can I use the value of the JSON in a second file. Can you help me?
  17. I saw those links but how can I apply the Sessions to my case?
  18. Can you give me an example of how do it?
  19. Hi, can I pass an array from one php file to another php file like this: First file: function NewPage(Day, Month, Year){xpto[0] = Day;xpto[1] = Month;xpto[2] = Year;location.href='new.php?xpto';} Second file (new.php): <?php$dayphp = $_GET[xpto[0]];$monthphp = $_GET[xpto[1]];$yearphp = $_GET[xpto[2]]; ?> I have tried but just got an error like this "Parse error: syntax error, unexpected '[', expecting ']' in C:\Program Files\EasyPHP-12.1\www\new.php on line 13" Can I do something similar?
  20. Well, the first file is a calendar. The second file appear when I click on a day of the calendar...now I want the month and the year of the day I clicked =)
  21. Hi, I have one html file where I use the following expression: <select name=selMonth onChange='changeCal()'>"; Then, I have another file, this one is a php file, where I want to use the selected value on the dropdown list select object. I tried to use the following expression in the php file but it didn't worked: var xpto = parseInt(document.calForm.selMonth.value); It presents me nothing... Can someone help me please? Regards,
×
×
  • Create New...