Jump to content

_DarkLink_

Members
  • Posts

    45
  • Joined

  • Last visited

    Never

Everything posted by _DarkLink_

  1. You may also use a meta-refresh. if(isset($_POST['submit'])) { //check inputs vs db if ($check) { echo "<meta http-equiv=\"refresh\" content=\"0;url=". $_SERVER['SERVER_NAME']."/include/process_renew.php\">"; } else { echo "<font color='red'>Username or Password did not match.</font> <br /><br />"; } }
  2. Meh, I was trying to find that "Thank You" button somewhere. But anyway, will do what you said.
  3. Oh my, it worked! I can't believe it, I have been wasting too much time on this little part of my project. I don't know how I may thank you enough for this. [EDIT]How do I thank someone?[EDIT] Thank you for putting your time in this and helping me.
  4. Hey is what the array contains: array(1) { [0]=> string(16) "QWERTY\r\nAZERTY" } It does not seem to be separated into two arrays. Thank you, more help is appreciated.
  5. Hello, I would really appreciate if you guys would have a look at this piece of code. <?php if(isset($_POST['add'])) { $self = $_SERVER['PHP_SELF']; //the $self variable equals this file $ipaddress = ("$_SERVER[REMOTE_ADDR]"); //the $ipaddress var equals users IP //connect $connect = mysql_connect($host,$username,$password) or die('<p class="error">Unable to connect to the database server at this time.</p>'); mysql_select_db($database,$connect) or die('<p class="error">Unable to connect to the database at this time.</p>'); //fetch data $data = htmlspecialchars($_POST['list']); $comment = mysql_real_escape_string($_POST['comment']); $data_lines = explode( "\r\n", $data ); $comment_lines = explode("\r\n", $comment); for($i=0;$i<count($data_lines);$i++) { $data_fields = explode( ",", $data_lines[$i]); $time = time(); $queryb = "INSERT INTO coords SET tag='{$data_fields[0]}', guild='{$data_fields[1]}', name='{$data_fields[2]}', base='{$data_fields[3]}', econ='{$data_fields[5]}', maxecon='{$data_fields[6]}', location='{$data_fields[4]}', comment='{$comment_lines[$i]}', ipaddress='$ipaddress' , date='$time';"; // if it succeeds, display message if (mysql_query($queryb)) { echo('<p class="success">Successful posting of ['.$data_fields[3].']!</p>'); } else { echo('<p class="error">Error could not post ['.$data_fields[3].'] to database!</p>'); } }//end for loop }//end if $_POST['add'] statement ?> As you can see, it gets data received from a form's submission and explodes them into lines. For $data, it explodes it again for each comma. It then inserts everything for each comma, in a new column and for each line, on a new row. Now for $comment, it should be inserting it on a new row for each line, which isn't doing it, it just inserts the whole comment into one single row. Been looking and testing at it for a few days now. The comment column is a varchar of 100 of length. So basically, it does everything i need it to do except inserting $comment on a new row for every line. Any help is appreciated. Thank you in advance.
  6. What he means is that you have to include session.php before you can use $session->logged_in. which means on every page that you would like to make it a member only page, you will have to put this before anything: <?php include("your/folder/to/session.php"); ?>
  7. Oh and since this is a PHP forum, I'll make a little PHP validation script too. <form name="testform" action="myphpfile.php" method="POST" onsubmit="return validate();"> <input type="checkbox" name="terms" value="on"> I accept the <a href="http://www.example.com/terms.html">Term and Conditions</a>. <input type="submit" value="Register" name="submit"> </form> PHP processing script: <?php if ($_POST['submit']) { if {$_POST['terms'] =="on") { //your piece of code that will execute if terms are checked. } else{ echo "Please accept the Terms and Contions first."; header("Refresh: 5; url=registrationform.html");//if it isn't checked, send back to the registration form in five seconds. } } ?> Hope it helps.
  8. First, as an example, to make a check box and a submit button in a form: <form name="testform" action="myphpfile.php" method="POST" onsubmit="return validate();"> <input type="checkbox" name="terms"> I accept the <a href="http://www.example.com/terms.html">Term and Conditions</a>. <input type="submit" value="Register" name="submit"> </form> Alright, so to validate if the check box is checked, there are two ways, you either use PHP to validate it AFTER the form is sent and send the user back to the form if it is not checked, Or simply use JavaScript to check it if it is checked BEFORE the form is sent, an example would be: <script type="text/javascript"> function validate(){ if (document.testform.terms.checked == false) { alert ( "Please accept the terms before continuing." ); return false; } else { return true; } } </script> So basically the JavaScript checks the form, on submit if the check box is checked, it it's not, send a little pop up message saying to check it and the form is not submitted. If it is checked, then let the form submit. Hope it helps.
  9. Hello, Is it just me or are you ending the else statement as soon as you started it? <?php if($_POST['submit']) { $db = mysql_connect($dbhost, $dbuser, $dbpassword); mysql_select_db($dbdatabase, $db); $sql = "INSERT INTO comments(blog_id, dateposted, name, comment) VALUES(". $validentry . ", NOW(),'" . $_POST['name'] . "','" . $_POST['comment'] . "');"; mysql_query($sql); header("Location: http://" . $HTTP_HOST . $SCRIPT_NAME . "?id=" . $validentry); } else { }//Here... ?> Try putting the ending curly bracket at the end of everything, after the closing HTML tags for example. Such as here: <?php require("footer.php"); }//Close the else statement. ?> Hope it helps.
  10. Hmm, does my code really look like it has no errors? ...
  11. No problem, I'm glad to know that you finally got it working. Don't forget to mark the topic solved by clicking on the "Topic Solved" button at the bottom left side of this page.
  12. You just need to click on that little "Topic Solved" button at the bottom left side of this page.
  13. Hmm, I'm almost out of ideas. =/ But anyway, can you tell me what does that piece of JavaScript exactly do? I can see that "translator.js" judging by it's name, it translates the word to Greek, but how exactly does it do it? I can also see an "onkeyup" event in the Greek text areas.
  14. Well, depending on the logic of things, you should put the connection before the code, since you have to be connected to the database before fetching data from it.
  15. You can always use strtolower() or strtoupper() to convert everything in both variables to upper case or lowercase. Try this: <?php $con = mysql_connect("servername", "username", "password"); if (!$con) { echo "<h2>Sorry, we cannot process your request at this time, please try again later</h2>\n"; echo "<a href=\"index.php?content=newquestion\">Try again</a><br>\n"; echo "<a href=\"index.php\">Return to Home</a>\n"; exit; }mysql_select_db("knowledge", $con) or die('Could not connect to database'); $plat_name = $_POST['plat_name']; $baduser = 0; // Check if platform name was entered if (trim($plat_name) == '') { echo "<h2><br><br>Sorry, you must enter a new platform name.</h2><br>\n"; echo "<a href=\"index.php?content=newplatform\">Try again</a><br>\n"; echo "<a href=\"index.php\">Return to Home</a>\n"; $baduser = 1; exit; } //Check if Platform is already in database $query = "SELECT plat_name from platform where plat_name = '$plat_name'"; $result = mysql_query($query); $row = mysql_fetch_array($result, MYSQL_ASSOC);if (strtolower($row['plat_name']) == strtolower($plat_name))//Changed this... { echo "<h2>Sorry, that Platform name is already taken.</h2><br>\n"; echo "<a href=\"index.php?content=newplatform\">Try again</a><br>\n"; echo "<a href=\"index.php\">Return to Home</a>\n"; $baduser = 1; }if ($baduser != 1) { //Everything passed, enter question into database $query = "INSERT into platform (plat_name) VALUES ('$plat_name')"; $result = mysql_query($query) or die('Sorry, we are unable to process your request.' . mysql_error()); } ?> [EDIT]Bah, went a little fasetr than me there. =/[/EDIT] Hope it helps.
  16. Those notices are warnings that are telling you to define the variables before it is being used. Such as defining $_POST['something'] before you use it, it is a change made to PHP 5, to my knowledge, it is not that important and can be ignored. For instance, I have made an attempt on remedying your code, I have made it all into one single PHP file and when you go on addWord.php, it should display the form and process the form when submitted. Here it is: <?php ini_set('display_errors',1); error_reporting (E_ALL ^ E_NOTICE); //if receive form submission if ($_POST['submit']) { /** PHP code inserted here */ $greekWord = $_POST['GreekWord']; $greekDef = $_POST['GreekDefinition']; $englishWord = $_POST['EnglishWord']; $englishDef = $_POST['EnglishDefinition']; $chapter = $_POST['chapter']; $section = $_POST['section']; //test to see if values being posted... echo $_POST['EnglishWord']; echo '<br />'; echo $_POST['EnglishDefinition']; echo "connection to the DB section of the code"; $conn = mysql_connect("localhost", "root") or die(mysql_error()); $db = mysql_select_db("test",$conn) or die(mysql_error()); echo "setting the SQL variables up"; echo "the query is here"; $query = "INSERT INTO word (GreekWord, GreekDefinition, EnglishWord, EnglishDefinition, Chapter, Sections) VALUES ('{$greekWord}','{$greekDef}','{$englishWord}','{$englishDef}','{$chapter}','{$section}')"; // echo query to validate echo '<br />'; echo $query; echo "exuctuing the query"; $exec = mysql_query($query, $conn) or die(mysql_error()); if($exec) { echo "query execution successful"; //echo "<a href=\"javascript:history.back();\">Please go back and fill out the missing fields</a>"; echo "Word added"; //header("Location:http://localhost/ninjatuna/wordAdded.html"); } else { echo "Failed to add word"; if($errmsg!="") { echo $errmsg; echo "<a href=\"javascript:history.back();\">Please go back and fill out the missing fields</a>"; exit; } } } else { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <link rel="stylesheet" type="text/css" href="layout.css"> <script type="text/javascript" src="translator.js"></script> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Welcome to LearnGreek.com (Work title)</title> </head> <body> <div id="header"> <h1>Welcome to LearnGreek.com</h1> </div> <div id="nav"> <ul> <li><a href="index.html">Home</a></li> <li><a href="Login.html">Login</a></li> <li><a href="Register.html">Register</a></li> <li><a href="Links.html">Links</a></li> </ul> </div> <div id="main"> <p> <form name="addwrd" action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST"> Greek Word: <input type="text" onkeyup="trans(this.id)" id="greek_word" name="GreekWord" size="20"><br><br> Greek Definition: <input type="text" onkeyup="trans(this.id)" id="greek_definition" name="GreekDefinition" size="20"><br><br> English Word: <input type="text" name="EnglishWord" size="30"><br><br> English Definition: <input type="text" name="EnglishDefinition" size="20"><br><br> Chapter: <input type="text" name="chapter" size="20"><br><br> Section: <input type="text" name="section" size="20"><br><br> <input type="submit" name="submit" value="Submit"> </form> </p> </div> </body> </html> <?php }// end else statement ?> If it still does not insert the two fields that you said, I would really love to see your SQL table structure, if you do not have the SQL code for your table, you should do a backup of your database with PHPMyAdmin and it should give you the code for the structure. Hope I didn't make any mistakes and helped.
  17. It is fairly easy, Just wrap the whole code in an "if else" statement if ($_POST['submit']) { $from1=$_SESSION['username']; $to1=$_GET['comp']; $comment1=$_POST['comment']; $query="INSERT INTO leaguecomments VALUES (NULL, '$to1','$comment1', now(), '$from1')"; if (!empty($_POST)) { if(!$comment1 || strlen($comment1 = trim($comment1)) == 0) echo "Comment not entered"; else if(!$comment1 || strlen($comment1 = trim($comment1)) < 10) echo "Comment too short, must be 10 characters at least"; else if (!$comment1 || strlen($comment1 = trim($comment1)) > 10){ echo "".$_SESSION['username'].", you have added a comment "; mysql_query($query);}} } else { // and then you put another } inside PHP tags after the HTML closing tags Hope it helps.
  18. You should turn on error reporting for your script and displaying SQL errors. And removing the '@' before the query to not prevent it from displaying errors if there are any. <?php ini_set('display_errors',1); error_reporting(E_ALL); /** PHP code inserted here */ $greekWord = $_POST['GreekWord']; $greekDef = $_POST['GreekDefinition']; $englishWord = $_POST['EnglishWord']; $englishDef = $_POST['EnglishDefinition']; $chapter = $_POST['chapter']; $section = $_POST['section']; //test to see if values being posted... echo $_POST['EnglishWord']; echo '<br />'; echo $_POST['EnglishDefinition']; echo "connection to the DB section of the code"; $conn = mysql_connect("localhost", "root") or die(mysql_error()); $db = mysql_select_db("test",$conn) or die(mysql_error()); echo "setting the SQL variables up"; // This is so the SQL statement is correctly formatted. $grkWrd = "'".$greekWord."'"; $grkDef = "'".$greekDef."'"; $engWrd = "'".$englishWord."'"; $engDef = "'".$englishDef."'"; $chptr = "'".$chapter."'"; $sctn = "'".$section."'"; echo "the query is here"; $query = "INSERT INTO word (GreekWord, GreekDefinition, EnglishWord, EnglishDefinition, Chapter, Sections) values ($grkWrd,$grkDef,$engWrd,$engDef,$chptr,$sctn)"; // echo query to validate echo '<br />'; echo $query; echo "exuctuing the query"; $exec = mysql_query($query, $conn) or die(mysql_error()); echo "query execution successful"; if($exec) { //echo "<a href=\"javascript:history.back();\">Please go back and fill out the missing fields</a>"; echo "Word added"; //header("Location:http://localhost/ninjatuna/wordAdded.html"); } else { if($errmsg!="") { echo($errmsg); echo "<a href=\"javascript:history.back();\">Please go back and fill out the missing fields</a>"; exit; } } ?> Try adding again to see if any errors come up. Hope I didn't make any mistakes and helped.
  19. No, what he means is take out, echo $mailSent; From your code, and please, I repeat, PLEASE put your code inside the code tags next time, it really is very hard to read through it. Hope it helps.
  20. Hmm, Try removing those single quotes... Replace: // fetch results $results = mysql_query("SELECT * FROM 'searchengine'"); With: $results = mysql_query("SELECT * FROM searchengine");
  21. Normally, no. Since a query is a demand for something. So in the piece of code that I attempted to correct had a demand for a demand for something, which doesn't make any sense. And simply the $construct variable is not the same as the $results variable.
  22. Hello again, I don't think you should be querying a query. Unless I'm wrong, This part, $stuff = get_stuff(mysql_query($results)); $output_html .= "<td width='197' height='270' align='left' valign='top'>$stuff</td>"; $output_html .= "<td width='23'></td>"; $stuff = get_stuff(mysql_query($results)); $output_html .= "<td width='197' align='center' valign='top'>$stuff</td>"; $output_html .= "<td width='21'></td>"; $stuff = get_stuff(mysql_query($results)); $output_html .= "<td width='199' align='right' valign='top'>$stuff</td>"; Should be: $stuff = get_stuff($results); $output_html .= "<td width='197' height='270' align='left' valign='top'>$stuff</td>"; $output_html .= "<td width='23'></td>"; $stuff = get_stuff($results); $output_html .= "<td width='197' align='center' valign='top'>$stuff</td>"; $output_html .= "<td width='21'></td>"; $stuff = get_stuff($results); $output_html .= "<td width='199' align='right' valign='top'>$stuff</td>"; Since you have already done a query at: // fetch results $results = mysql_query("SELECT * FROM 'searchengine'"); Hope it helps.
  23. Okay so the results are not displayed like you want it to? So you mean that it is not displayed at all? If so, then try to echo $stuff. Such as replacing this: $stuff = get_stuff(mysql_query($results)); $output_html .= "<td width='197' height='270' align='left' valign='top'>$stuff</td>"; $output_html .= "<td width='23'></td>"; $stuff = get_stuff(mysql_query($results)); $output_html .= "<td width='197' align='center' valign='top'>$stuff</td>"; $output_html .= "<td width='21'></td>"; $stuff = get_stuff(mysql_query($results)); $output_html .= "<td width='199' align='right' valign='top'>$stuff</td>"; With: $stuff = get_stuff(mysql_query($results)); echo $stuff; $output_html .= "<td width='197' height='270' align='left' valign='top'>$stuff</td>"; $output_html .= "<td width='23'></td>"; $stuff = get_stuff(mysql_query($results)); echo $stuff; $output_html .= "<td width='197' align='center' valign='top'>$stuff</td>"; $output_html .= "<td width='21'></td>"; $stuff = get_stuff(mysql_query($results)); echo $stuff; $output_html .= "<td width='199' align='right' valign='top'>$stuff</td>"; Or maybe I have it wrong? Anyway, hope I helped and did not make any mistakes.
×
×
  • 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.