PHP - Moved: Clickable Smiley Code Issue
This topic has been moved to JavaScript Help.
http://www.phpfreaks.com/forums/index.php?topic=320820.0 Similar TutorialsThis one im took from php Code: [Select] print "<form action='registration.php' method='post'onsubmit='return msg();'>"; print "Your message:<br>"; print "<textarea name='message' cols='40' rows='2'></textarea><br>"; print "<a onClick=\"addSmiley(':)')\"><img src='smile.gif'></a> "; print "<a onClick=\"addSmiley(':(')\"><img src='blush.gif'></a> "; print "<a onClick=\"addSmiley(';)')\"><img src='images/wink.gif'></a> "; print "<input type='submit' name='submit' value='Set Name'></form>"; print "<script language=\"Java Script\" type=\"text/javascript\">\n"; print "function addSmiley(a)\n"; print "{\n"; print "document.form.message.value += a;"; print "document.form.message.focus();\n"; print "}\n"; print "</script>\n"; print "<br><br>"; and i converted it to html Code: [Select] <html> <form action='registration.php' method='post'> Your message:<br><textarea name='message' cols='40' rows='2'></textarea><br> <a onClick=\"addSmiley(':)')\"><img src='smile.gif'></a> <a onClick=\"addSmiley(':(')\"><img src='blush.gif'></a> <a onClick=\"addSmiley(';)')\"><img src='images/wink.gif'></a> <input type='submit' name='submit' value='Set Name'></form> <script type="text/javascript">+"\n" function addSmiley(a)+"\n" { "\n" document.form.message.value + = a document.form.message.focus()+"\n" } "\n" </script> "\n" <br> <br> </html> but that html problem is im cannot integrate the javascript im means canot click the smiley button la may i know what is wrong This topic has been moved to CSS Help. http://www.phpfreaks.com/forums/index.php?topic=327840.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=328179.0 This topic has been moved to Linux. http://www.phpfreaks.com/forums/index.php?topic=317047.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=342389.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=348545.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=349184.0 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=348680.0 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=334644.0 This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=322069.0 This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=347219.0 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=353224.0 This topic has been moved to Installation in Windows. http://www.phpfreaks.com/forums/index.php?topic=347714.0 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=328244.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=351266.0 Can someone take a look at line 36 in this code? This code pulls data from a MySQL database & displays it in a form. Then I can edit the data & click submit & it updates the MySQL database. It then, sends an email to the email address on line 35. Again, all of this works until I start editing line 36 to send the location, first name, & last name within the message of the email. What is the code so I can get an email with the first name, last name & location? Code: [Select] <?php # edit_dqa.php $page_title = 'Edit a Record'; $con = mysql_connect("localhost","uname","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("psrflow", $con); if ( (isset($_GET['id'])) && (is_numeric($_GET['id'])) ) { $id = $_GET['id']; } elseif ( (isset($_POST['id'])) && (is_numeric($_POST['id'])) ) { // Form has been submitted. $id = $_POST['id']; } else { // No valid ID, kill the script. echo '<h1 id="mainhead">Page Error</h1> <p class="error">This page has been accessed in error.</p><p><br /><br /></p>'; include ('./includes/footer.html'); exit(); } $query = "UPDATE psrinfo SET fname='$fn', lname='$ln', location='$loc' WHERE fid=$id"; $result = @mysql_query ($query); // Run the query. // Send Email switch ('location') { case 'location1': echo $EmailAddress = 'myemail@yahoo.com'; break; } $EmailAddress = 'myemail@yahoo.com'; $Message = "Someone has edited the information below."; Location : {$_REQUEST['location']}<br>First Name : {$_REQUEST['fname']}<br>Last Name : {$_REQUEST['lname']}" $Headers = "MIME-Version: 1.0\n"; $Headers = "Content-type: text/html; charset=iso-8859-1\n"; $Subject = "Please Change"; $Headers = "To: DQA <$EmailAddress>\n"; $Headers = "From: anotheremail@yahoo.com \n"; if (mail($EmailAddress, $Subject, $Message, $Headers)) { $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); if ((substr($url, -1) == '/') OR (substr($url, -1) == '//')) { $url = substr ($url, 0, -1); } $url ='/flow/index.html'; header("Location: $url"); exit(); } else { // Report the errors. echo '<h1 id="mainhead">Error!</h1> <p class="error">The following error(s) occurred:<br />'; foreach ($errors as $msg) { // Print each error. echo " - $msg<br />\n"; } echo '</p><p>Please try again.</p><p><br /></p>'; } // End of if (empty($errors)) IF. } // End of submit conditional. // Retrieve the user's information. $query = "SELECT pacts, fname, lname, location WHERE fid = " . $_REQUEST['id']; $result = @mysql_query ($query); // Run the query. if (mysql_num_rows($result) == 1) { // Valid user ID, show the form. $row = mysql_fetch_array ($result, MYSQL_NUM); ?> <?php echo '<form action="edit_dqa.php" method="post"> <fieldset><legend><h1> You are editing a record!</h1></legend> <b>First Name:</b> <br><input type="text" name="fname" size="15" maxlength="30" value="'.$row[1].'" /><br /> <b>Last Name:</b> <br><input type="text" name="lname" size="15" maxlength="30" value="'.$row[2].'" /><br /> <b>Location: </b><br><input type="text" name="location" size="15" maxlength="30" value="'.$row[5].'" /><br> br> <br> </fieldset> <div align="left"><input type="submit" name="submit" value="Submit" /></div> <input type="hidden" name="submitted" value="TRUE" /> <input type="hidden" name="id" value="' . $id . '" /> </form>'; } else { // Not a valid user ID. echo '<h1 id="mainhead">Page Error</h1> <p class="error">This page has been accessed in error.</p><p><br /><br /></p>'; } mysql_close(); // Close the database connection. ?> ok, I thought I had this working but I guess not. Once I click the submit button the email goes but I need to be redirected to a web page named http://myserver/notification_sent.php I edited the line: <form method="post"> to look like <form method="post" action="http://myserver/notification_sent.php"> & I then get redirected to the page I need but the email don't go out. Code: [Select] $mailheaders = "From: Reporting System<rps@yahoo.org>"; $destination = array(); if (!empty($_POST['notify_jane'])) $destination[] = 'email1@yahoo.org'; if (!empty($_POST['notify_john'])) $destination[] = 'email2@yahoo.org'; if ($destination) { mail(join(', ', $destination), 'Document Added/Updated', 'This is a test notification', $mailheaders); } ?> <form method="post"> <input type="hidden" name="formsent" value="true" /> <br/> If you do not need to send a notification to someone you can close this window. If you do, choose the name(s) below and click submit. <br/>------------------------------------------------------- <br/>Check this box <input autocomplete="off" type="checkbox" name="notify_jane" value="yes" /> to send <strong>John Doe</strong> a notification. <br/>Check this box <input autocomplete="off" type="checkbox" name="notify_jane" value="yes" /> to send <strong>Jane Doe</strong> a notification. <br> <br> <input type="submit" value="Submit" /> <br/>------------------------------------------------------- </form> <?php The code snippet below works fine with PHP 5.3 (register_globals = Off) but does NOT give the same results with PHP 5.5: $verhash = md5($tstamp."salt"); if ($hash != $verhash) { $_SESSION['direct'] = 1; if(isset($_SESSION['ntrd'])) { unset($_SESSION['ntrd']); } if(isset($_SESSION['rntr'])) { unset($_SESSION['rntr']); } header('refresh: 0; url=/accessDenied.php'); exit; }I'm not sure if there is a problem with the above snippet or with some other part of the code but I always get redirected to the 'accessDenied.php' page with PHP 5.5. Can someone tell me if the snippet above would output differently on PHP 5.5? Thanks, Jeff Edited by jeffshead, 04 November 2014 - 08:36 PM. I have a pretty basic PHP log in code connected to a database of register users. However, it's not allowing any users to enter? Could someone please review the code and let me know if you find any errors? //Create query $qry="SELECT * FROM customers WHERE username='$login' AND password='".md5($_POST['password'])."'"; $result=mysql_query($qry); //Check whether the query was successful or not if($result) { if(mysql_num_rows($result) == 1) { //Login Successful session_regenerate_id(); $member = mysql_fetch_assoc($result); $_SESSION['SESS_MEMBER_ID'] = $member['id']; $_SESSION['SESS_FIRST_NAME'] = $member['fname']; $_SESSION['SESS_LAST_NAME'] = $member['lname']; session_write_close(); header("location: key_catalog.php"); exit(); }else { //Login failed header("location: login-failed.php"); exit(); } }else { die("Query failed"); } ?> im working on a php syntax highlighter for a bbeditor. basically all text within code tags will be placed into the function parse_code(). It works fine until i add the code to instantiate a class within the tags. This is supposed to just be a string but it looks like the 'e' modifier of preg_replace is recognising the code as php and executing it. Is there any way around this? Heres the regex: Code: [Select] '|\[code=(.*?)\](.*?)\[\/code\]|sie', 'self::parse_code("\\1", "\\2")', and the parse_code method public static function parse_code($code, $content) { $words = explode(' ', $content); dump($words); $keywords = array( 'php_words' => array( 'function', 'echo', 'class', 'new', ), ); foreach($words as $key => $value) { foreach($keywords as $group => $array) { foreach($array as $keyword) { $words[$key] = preg_replace('|'.$keyword.'|si', '<span class="'.$group.'">'.$keyword.'</span>', $words[$key]); } } $words[$key] = preg_replace("|\\'(.*?)\\'|si", '<span class="string">\'\\1\'</span>', $words[$key]); } $content = implode(' ', $words); $lines = explode("\n", $content); unset($lines[0]); for($i=1; $i<count($lines); $i++) { $lines[$i] = '<p class="line_number">'.$i.'. </p>'.$lines[$i]; } $content = implode("\n", $lines); return stripslashes('<blockquote class="code"><div class="code_header"><p>'.$code.'</p></div><div class="code_content"><p>'.$content.'</p></div></blockquote>'); } |