Jump to content

RonnieCosta50

Members
  • Posts

    28
  • Joined

  • Last visited

RonnieCosta50's Achievements

Newbie

Newbie (1/5)

1

Reputation

  1. Thank you. That was exactly what I needed to get this working.
  2. I don't know any AJAX so that option is out the window. As for submitting the form to search.php... If I submit a form then it will reload the whole website. I only want it to search the database and display the data into the website without reloading the website. There are many textboxes and it would not work to reload the page every time a user switches textboxes.
  3. As for your 2 fields that don't clear when you submit form and the page reloads... I'm assuming your in the testing phase of your website and you probably do what I do when I test. Check that you didn't accidentally forget to delete the initial value of both of those textboxes. I always set initial values so that I don't have to keep filling in the form to make sure it is adding to the database. When you finished the adding to database code, it is likely that you forgot to delete the initial values. I don't see anything in your code that could do that by itself.
  4. I have a textbox. When the text that is typed into the textbox changes, I want to search my database for what is in the textbox. I want to do this rather than a search button because my website is really complicated and I'm simplifying it in my explanation to make it easy to understand. I currently have an alert in my textbox that displays the text that was typed in the textbox on change. It looks like this. <input name="txtPlayerName" tabindex="0" style="width: 150px; background-color: #BBAE85;" maxlength="15" required="required" autofocus="autofocus" placeholder="LoU screen name" onchange="alert(this.value)" /> I have a seperate php file called search.php. It contains my code to search the database based on criteria in my input textboxes. Question: How do I tell the textbox to run search.php onChange?
  5. Try taking the echos out of php mode. echo " ?> <script>alert('Product successfully added'</script>) <?php ";
  6. Hey buddy. Since you started over, I can see an error in your echo. echo "$fn"; When you want to write something specific, it is a string. You put that in quotes. example: echo"Ronnie is awesome"; When you are using a variable, you don't put it in quotes. $fn="Ronnie is awesome"; echo $fn; You shouldn't have started over.
  7. You can't do that with those else statements. You can only have 1 else statement per if statement. Put all those echos in a single else statment and watch it work. You will obviously want to make if statements for your echos though so if email is wrong then echo email is wrong blah blah blah. Just don't use more than one else per if. You can also use elseif
  8. Don't understand the problem. What is your final intention?
  9. Thanks for the code. It didn't work though but I modified it to work. Here is the code that worked for me for anyone else who reads this and wants to do this. Note: you should not do this. It's a security risk. I'm doing it because I have nothing on my server space and I'm learning php with it so I don't have to keep uploading the file to the server. <html><head><title>Execute PHP Code In A Textbox</title></head><body> <form action="" method="post"> <textarea name="code" cols="50" rows="20"></textarea><br> <input type="submit" name="submit" value="Execute"> </form> <?php if (isset($_POST['submit'])){ $code = $_POST['code']; eval($code); } ?> </body></html>
  10. Yeah now that you said it I guess if someone know my website then they could type php code to ask for the connection details and then they have all they need. Guess it's a bad idea. Thanks .
  11. Before I agree on exploding but then if the user inputs something like this, "What do you do if you step on a mine?" then you should create a list of words to take away from the search parameters. Put that list in a seperate php. Get rid of words in the string such as the words "the, if, you, do, a, etc". So now the search becomes "step on mine". I think the search results would be more effecitve. Then explode step on mine and put the new string in the variable %$quest_search%
  12. I have a textbox and a submit button. It's easy to make an echo so whatever is typed in the textbox, echos under the textbox. I want to do something a little more complicated. I want to run the php code that is entered in the textbox. For example if I put this in the textbox <?php echo"Hello World";?> or if I put an if statement in the textbox I want it to run it. I am trying to learn php and it would be great if I could just input code into a textbox to see the result rather than have to upload the file to the FTP server every time. Sometimes I'm not at my home computer and I want to sample some code I read on the php manual. Question: Is it possible to run php code that is typed into a textbox? <!DOCTYPE html> <html> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Learn PHP</title> </head> <body> <form method="post"> <input name="txtTextbox" style="width: 500px" type="text"><br> <?php $txtTextbox = $_POST['txtTextbox']; $search = $_POST['btnSubmit']; if ($search) { // Here's the part I need help on. echo '<p>';?> $txtTextbox; <?php echo '</p>'; // Assume I typed Hello World <?php echo $txtTextbox;?> in the textbox } echo'<br>'; ?> <input name="btnSubmit" type="submit" value="submit"> </form> </body> </html>
  13. 1. First off you should not require once your database connection. You should close the connection after your done using it to free up the server. 2. Your form method is "get". I'd use "post". 3. Your sql statement says '%$searchSubmit%' but you never told it what that variable was. Right above that line write in $searchSubmit = $_POST['searchSubmit']; I think that's about it. Don't forget to mark me as Solved if it worked.
  14. I guess if you don't want to use a database table, you could just echo. Replace this part... // DISPLAYS DATA FROM DATABASE INTO HTML TABLE while($rows=mysql_fetch_array($qrySELECT)) { echo'<tr>'; echo'<td style="width: 100px">'.$rows[$dbColumnName1].'</td>'; //$dbColumnName is the name is the column in your database. echo'<td style="width: 100px">'.$rows[$dbColumnName2].'</td>'; echo'</tr>'; } With this... // DISPLAYS DATA FROM DATABASE WITH ECHO while($rows=mysql_fetch_array($qrySELECT)) { echo'$rows[$dbColumnName1] </br>'; //$dbColumnName is the name is the column in your database. echo'$rows[$dbColumnName2] </br>'; }
  15. I think this is what you want. You want the user to search for something in the database and have it displayed. I'm assuming it will display more than one result so you will need an html table. <body> <form name="search" method="post"> // "search" is the name of the button. <!--here's a textbox for input.--> <input name="wsTextbox1" tabindex="0" style="width: 150px; background-color: #BBAE85;" maxlength="15" required="required" autofocus="autofocus" placeholder="Enter Search Criteria" /> <!--Here's a submit button--> <input type="submit" name="btnSubmit" value="Submit" class="button" style="width: 80px"/> <table> <?php // SEARCHES FOR DATA IN YOUR DATABASE $search = $_POST['search']; // The variable name $search is equal to the click of the search button. if ($search) // If the search button is clicked, { // since you want everything on one page, you will have to add code here for your database connection. // I'm just going to use multiple pages to demonstrate. include 'dbConnect.php'; // Connects to database. include 'dbTableName.php'; // Gets the database table name. include 'dbTableColumns.php'; // Gets the database table column names. // This is a sample sql statement. Modify it to the website criteria. $sqlSELECT = "SELECT * FROM $dbTableName WHERE $dbColumnName1 LIKE '%$wsTextbox1%' ORDER BY $dbColumn2 DESC, $dbColumn2 DESC LIMIT 10"; $qrySELECT=mysql_query("$sqlSELECT"); } // DISPLAYS DATA FROM DATABASE INTO HTML TABLE while($rows=mysql_fetch_array($qrySELECT)) { echo'<tr>'; echo'<td style="width: 100px">'.$rows[$dbColumnName1].'</td>'; //$dbColumnName is the name is the column in your database. echo'<td style="width: 100px">'.$rows[$dbColumnName2].'</td>'; echo'</tr>'; } </table></form></body> ?> This is how you refresh a page. But you don't need to do this because when you press the submit button it will reload the page automatically. But here's the code anyway for reference. echo "<meta http-equiv=\"refresh\" content=\"0;URL=../editHere.php\">"; Change the part that says ../editHere.php to match your directory and file name.
×
×
  • 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.