Jump to content

willscarlet

New Members
  • Posts

    9
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

willscarlet's Achievements

Member

Member (2/5)

0

Reputation

  1. im glad i came here, I would have been all messed up had i got this to somehow work right it seems. Well, thank you guys for your help. Seems like I will be trying this again from scratch
  2. Oh im sorry, I guess i was misleading before, I had built an old CMS years ago using PHP/MySQL now im trying to get back into it all and im finding that MySQL is no longer suggested so im xfering everything over to PDO and updating my general coding standards. So alllll that being said this is new code that I kinda pieced together from tutorials, ive never used this code before but it looked like it was fairly straight forward and good. Just looking for a simple bot safe contact form really.
  3. awesome, ill see what all it takes to update it on my webserver, but if thats the only problem then awesome thanks a bunch
  4. Hi guys, im updating all my old php/MySQL to newer coding standards (or trying to at least). So heres what I have so far. The form makes you enter all the required fields but instead of it sending the message, it just appends it all to the address bar after refreshing the page. Im not sure exactly whats wrong with it but this is kinda new to me so any help would be greatly appreciated EDIT: Im getting this error now, im sure its something simple but im just not seeing it. i dont see where or how to load this dynamic library. [21-Nov-2016 13:36:28] PHP Warning: PHP Startup: Unable to load dynamic library '/usr/php/54/usr/lib64/php/modules/imagick.so' - /usr/php/54/usr/lib64/php/modules/imagick.so: undefined symbol: zend_new_interned_string in Unknown on line 0 <script> function _(id){ return document.getElementById(id); } function submitForm(){ _("mybtn").disabled = true; _("status").innerHTML = 'Please Wait...'; var formdata = new FormData(); formdata.append( "n", _("n").value ); formdata.append( "e", _("e").value ); formdata.append( "p", _("p").value ); formdata.append( "m", _("m").value ); var ajax = new XMLHttpRequest(); ajax.open( "POST", "parser.php" ); ajax.onreadystatechange = function() { if(ajax.readyState == 4 && ajax.status == 200) { if(ajax.responseText == "success"){ _("my_form").innerHTML = '<h2>Thanks '+_("n").value+', your message has been sent.</h2>'; } else { _("status").innerHTML = ajax.responseText; _("mybtn").disabled = false; } } } ajax.send( formdata ); } </script> <div class="contact-grid agileits w3layouts"> <form id="my_form" onsubmit="submitForm(); returm false;"> <input type="text" id="n" class="text agileits w3layouts" name="Name" placeholder="YOUR NAME" required=""> <input type="email" id="e" class="text agileits w3layouts email" name="Email" placeholder="YOUR EMAIL" required=""> <input type="text" id="p" class="text agileits w3layouts" name="Phone" placeholder="YOUR PHONE" required=""> <textarea name="Message" id="m" placeholder="MESSAGE" required=""></textarea> <input type="submit" id="mybtn" class="more_btn agileits w3layouts" value="SEND MESSAGE"><span id="status"></span> </form> </div> And here is the parser. <?php if( isset($_POST['n']) && isset($_POST['e']) && isset($_POST['m']) ){ $n = $_POST['n']; $e = $_POST['e']; $m = nl2br($_POST['m']); $to = "brunsoncomputerservice@gmail.com"; $from = $e; $subject = 'Online Contact Form'; $message = '<b>Name:</b> '.$n.' <br><b>Email:</b> '.$e.' <br><b>Phone:</b> '.$p.'<p>'.$m.'</p>'; $headers = "From: $from\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\n"; if( mail($to, $subject, $message, $headers) ){ echo "success"; } else { echo "The server failed to send the message. Please try again later."; } } ?>
  5. Awesome. will do. thank you as well for the advice ive not messed with PHP in a very long time, so You guys will likely see me posting more frequently when im screwing something up.
  6. Ah, I see it now. Im sorry to have bothered you guys with it, ive been staring at this project so long it just all ran together I guess. needed to replace :name with :student_name. Thanks for humoring me
  7. New to PDO having trouble with a simple UPDATE feature. Im sure its a simple thing im just over looking it. any help would be much appreciated <?php require_once('dbcon.php'); if(isset($_POST['btn_submit'])){ $student_id = $_POST['txt_student_id']; $student_name = $_POST['txt_student_name']; $age = $_POST['txt_age']; $email = $_POST['txt_email']; $address = $_POST['txt_address']; $dob = $_POST['txt_dob']; if(!empty($student_name)){ try { $stmt = $con->prepare("UPDATE tb_students set student_name= :name, age = :age, email = :email, address = :address, dob = :dob WHERE student_id = :student_id"); $stmt->execute(array(':student_name'=>$student_name, ':age'=>$age, ':email'=>$email, ':address'=>$address, ':dob'=>$dob, ':student_id'=>$student_id)); if($stmt){ header('Location:index.php'); } }catch(PDOException $ex){ echo $ex->getmessage(); } }else{ echo "INPUT NAME"; } } $student_id = 0; $student_name = ''; $age = 0; $email = ''; $address = ''; $dob = ''; if(isset($_GET['id'])){ $id = $_GET['id']; $stmt = $con->prepare('SELECT * FROM tb_students WHERE student_id = :id'); $stmt->execute(array(':id'=>$id)); $row = $stmt->fetch(); $student_id = $row['student_id']; $student_name = $row['student_name']; $age = $row['age']; $email = $row['email']; $address = $row['address']; $dob = $row['dob']; } ?> <h2>Edit Student</h2> <form action="" method="post"> <table cellpadding="5px"> <tr> <tr> <td>Student Name</td> <td><input type="text" name="txt_student_name" value="<?=$student_name;?>"></td> </tr> <tr> <td>Age</td> <td><input type="text" name="txt_age" value="<?=$age;?>"></td> </tr> <tr> <td>Email</td> <td><input type="text" name="txt_email" value="<?=$email;?>"></td> </tr> <tr> <td>Address</td> <td><input type="text" name="txt_address" value="<?=$address;?>"></td> </tr> <tr> <td>D.O.B</td> <td><input type="text" name="txt_dob" value="<?=$dob;?>"></td> </tr> <tr> <td></td> <td><input type="hidden" name="txt_student_id" value="<?=$student_id;?>"></td> <td><input type="submit" name="btn_submit"></td> </tr> </table> </form>
  8. Sorry, as for nesting functions, I was simply following a youtube tutorial from Alex at the php academy. however, there were a few flaws in his programming and they never got around to being fixed and updated on youtube. If you guys know a better tutorial set for a user registration/login system than his I would be more than happy to go through and learn it. and I thank you guys for taking teh time to look at my problem though.
  9. Hello everyone, I am new here so if this is being done wrong, please correct me. I am working on a script to let users register to my site, it will send them an email with a link to confirm. The email is being sent, but the link come up throwing one of the pre made errors I had made $errors[] = 'We had problems activating your account'; the code for this page is: Any tips or advice would be greatly appreciated. <?php ob_start(); include 'core/init.php'; logged_in_redirect(); include 'includes/overall/overallheader.php'; if (isset($_GET['success']) === true && empty($_GET['success']) === true) { ?> <h2>Thanks, we have activated your account...</h2><br> <p>You are free to log in</p> <?php } else if (isset($_GET['email'], $_GET['email_code']) === true) { $email = trim($_GET['email']); $email_code = trim($_GET['email_code']); if (email_exists($email) === false) { $errors[] = 'Oops, something went wrong, and we could not find that email address.'; } else if (activate($email, $email_code) === false) { $errors[] = 'We had problems activating your account'; } if (empty($errors) === false) { ?> <h2>Oops...</h2> <?php echo output_errors($errors); } else { header ('Location: activate.php?success'); } } else { header('Location: index.php'); exit(); } include 'includes/overall/overallfooter.php'; ?> the activate function i wrote to call to do this job is: function activate($email, $email_code) { $email = mysql_real_escape_string($email); $email_code = mysql_real_escape_string($email_code); if (mysql_result(mysql_query("SELECT COUNT(user_id) FROM users WHERE email = '$email' AND email_code = '$email_code' AND active = 0"), 0) == 1) { mysql_query("UPDATE users SET active = 1 WHERE email = '$email'"); return true; } else { return false; } }
×
×
  • 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.