Jump to content

downah

Members
  • Posts

    127
  • Joined

  • Last visited

Posts posted by downah

  1. Hi guys, finally codeigniter seems to make a little sense when I gave it another go making a simple project and learning individual things to get there as opposed to just following the “blog tutorial”.. However I am trying to submit a form and do it through ajax/jquery so that the other page doesn’t show and everything happens in one page.

    This is from my view where the form and jquery is:

    jquery:

     

    <script>
      $(function(){
       $("#form-signin").submit(function(){
    	 dataString = $("#form-signin").serialize();
    
    	 $.ajax({
    	   type: "POST",
    	   url: "<?php echo base_url(); ?>index.php/welcome/addmovie",
    	   data: dataString,
    
    	   success: function(data){
    		   alert('Successful!');
    	   }
    
    	 });
    
    	 return false;  //stop the actual form post !important!
    
      });
      });
    </script>
    

     

    form:

     

    
       <form class="form-signin" method="post" id="form-signin">
        <h4 class="form-signin-heading">Add a Movie</h4>
        <input type="text" class="input-block-level" placeholder="Movie Title">
        <input type="text" class="input-block-level" placeholder="URL">
        <input type="number" class="" min="1" max="100" placeholder="Jamies Score">
        <input type="number" class="" min="1" max="100" placeholder="Kellys Score">
        <button class="btn btn-large btn-primary" type="submit">Add</button>
      </form>
    

     

    It seems nothing happens when you click the submit button and I’ve put the script at the bottom of the page just before </body> as it seems when I put it under the form it doesn’t load the rest of the code below it? I am very new with jquery so please be kind.

    I don’t have anything in the script which the jquery should load (public function addmovie in the welcome controller) so it should return successfully I think?

    I hope someone can help me out!

     

    PS Using this tutorial: http://optimiseblog....niter-and-ajax/

  2. I am getting the same malware warning on your web page, why is it redirecting to verygoods-2014.ru ?? if your files really have nothing to do with that then u might want to call up your host and check your server

  3. Think about it logically, how does this script work and what do you need?

     

    To add news you need a page, with a text input for subject, a text area for content in a form with a submit button, this links up to a php script which then in return takes those values from the previous form, and puts them in the database.

     

    You need a page which displays news, this will contain a looper that gets all news out the database and displays it.

     

    You need a script on cron job (timed on the server) so that the script will run at a specific time every day (to move news to old news)

     

    And from there you can start building more exciting features like editing and deleting news etc :) a fancy text area maybe?

  4. Hi guys,

     

    Small (or big) problem once again

     

    I am using a simple html form, on submit action calls a php (mail) script.. now this script takes a little while to finish as there are some time limits in there before sending another mail.. I expected it to load a blank page, or at least display everything before loop.. but it didn't, instead it sort of "hangs" at the form stuck (although you can see the url of the script is loading in the browser bar) and once the script is finished it loads all the output on the page.. so I started looking at some ways of how to make this loading image.. or atleast let the user know something is happening, and that the script is working.

     

    I saw some stuff on stackover flow and included this, which was supposed to show a loading image where the submit button is, but I don't think it works because it isn't loading the page with the form anymore.. but the running the php loop, although I am going to let you see it anyway in the hope of.. something:

            $('#loading_image').show(); // show loading image, as request is about to start
    $.ajax({
        url: '..',
        type: '..',
        complete: function() {
            // request is complete, regardless of error or success, so hide image
            $('#loading_image').hide();
        }
    });
    $('#myform').submit(function() {
        $('#loading_image').show(); // show animation
        return true; // allow regular form submission
    });
    

     

    and my form

     

                               						<form method="post" action="sendeveryone.php" id="myform" onReset="return confirm('Do you really want to reset the form?')">
                    		<fieldset>
                    		Please note:  All e-mails start with "Dear {MEMBER_NAME}, " If you would like to mention their username in the body of your email, all you have to do is type '{MEMBER_NAME}' and it will replace it to their username.<br><br>
                            <br>
                                <label class="control-label" for="subject">Subject</label>
    
                                    <input id="subject" name="subject" class="span5" type="text">
                      
                         <label class="control-label" for="body">Body</label>
                      
    <div class="row-fluid">
            <div class="utopia-widget-content-nopadding">
                <div class="span12 text-editor">
                    <textarea id="input" name="input"></textarea>
                </div>
            </div>
        </div>
    
    <br><img src="myloadingimage.gif" style="display: none;" id="loading_image">
    
                            <button class="btn btn-large btn-primary span5" type="submit">Send</button>
                            <button class="btn btn-large span5" type="reset">Cancel</button>
                    
                      		</fieldset>
                            </form>
    

     

    This didn't work.. anyone has any hints or tips for me or other ways of going around this?

  5. I just got my script working.. I'll post it here:

     

    <?php
    // Grab our config settings
    require_once($_SERVER['DOCUMENT_ROOT'].'/mail/config.php');
    
    // Grab the FreakMailer class
    require_once($_SERVER['DOCUMENT_ROOT'].'/mail/lib/MailClass.inc');
    
    //set execution time limit to 5 minutes 
    
    $safeMode = ( @ini_get("safe_mode") == 'On' || @ini_get("safe_mode") === 1 ) ? TRUE : FALSE;
    if ( $safeMode === FALSE ) {
      set_time_limit(300); // Sets maximum execution time to 5 minutes (300 seconds)
      // ini_set("max_execution_time", "300"); // this does the same as "set_time_limit(300)"
    }
    
    echo "max_execution_time " . ini_get('max_execution_time') . "<br>";
    
    
    //db connection
    $con = mysql_connect("xx","xx","xx");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    
    mysql_select_db("xx", $con);
    
    // Setup body
    $textBody = "Dear {MEMBER_NAME},\n\nCheck out PHP Freaks: http://www.phpfreaks.com\n\nSincerely,\nAdmin";
    $htmlBody = "Dear {MEMBER_NAME},<br /><br />Check out PHP Freaks: http://www.phpfreaks.com<br /><br />Sincerely,<br />Admin";
    
    // instantiate the class
    $mailer = new FreakMailer();
    
    // Get the user's Email
    $sql = mysql_query("SELECT displayname,email FROM engine4_users2")or die(mysql_error());
    
    
    //lets reset the time limit of the server everytime an email is sent to bypass maximum
    while (1==1) {
      set_time_limit(30); // sets (or resets) maximum  execution time to 30 seconds)
      // .... put code to process in here
    
    
      		while($row = mysql_fetch_object($sql))
    	{
        	// Send the emails in this loop.
        	$member_name = $row->displayname;
    	$mailer->AddAddress($row->email);
    
    
        	
            $mailer->Body = str_replace('{MEMBER_NAME}', $member_name, $htmlBody);
            $mailer->IsHTML(true);
            $mailer->AltBody = str_replace('{MEMBER_NAME}', $member_name, $textBody);
    
    
    
        	$mailer->Send();
        	$mailer->ClearAddresses();
        	$mailer->ClearAttachments();
        	$mailer->IsHTML(false);
        	echo "Mail sent to: " . $member_name . "<br />";
    	}
      
      
      
    
      usleep(1000000); // sleep for 1 million micro seconds - will not work with Windows servers / PHP4
      // sleep(1); // sleep for 1 seconds (use with Windows servers / PHP4
      if (1!=1) {
        break;
      }
    }
    
    
    
    ?>
    
    

     

    Just change the query, and follow the tutorial in my thread and you'll get it :)

     

    If not let me know and I'll help you!

  6. Got it working, incase anyone else is wondering here is the working code:

     

    <?php
    // Grab our config settings
    require_once($_SERVER['DOCUMENT_ROOT'].'/mail/config.php');
    
    // Grab the FreakMailer class
    require_once($_SERVER['DOCUMENT_ROOT'].'/mail/lib/MailClass.inc');
    
    //set execution time limit to 5 minutes 
    
    $safeMode = ( @ini_get("safe_mode") == 'On' || @ini_get("safe_mode") === 1 ) ? TRUE : FALSE;
    if ( $safeMode === FALSE ) {
      set_time_limit(300); // Sets maximum execution time to 5 minutes (300 seconds)
      // ini_set("max_execution_time", "300"); // this does the same as "set_time_limit(300)"
    }
    
    echo "max_execution_time " . ini_get('max_execution_time') . "<br>";
    
    
    //db connection
    $con = mysql_connect("xx","xx","xx");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    
    mysql_select_db("xx", $con);
    
    // Setup body
    $textBody = "Dear {MEMBER_NAME},\n\nCheck out PHP Freaks: http://www.phpfreaks.com\n\nSincerely,\nAdmin";
    $htmlBody = "Dear {MEMBER_NAME},<br /><br />Check out PHP Freaks: http://www.phpfreaks.com<br /><br />Sincerely,<br />Admin";
    
    // instantiate the class
    $mailer = new FreakMailer();
    
    // Get the user's Email
    $sql = mysql_query("SELECT displayname,email FROM engine4_users2")or die(mysql_error());
    
    
    //lets reset the time limit of the server everytime an email is sent to bypass maximum
    while (1==1) {
      set_time_limit(30); // sets (or resets) maximum  execution time to 30 seconds)
      // .... put code to process in here
    
    
      		while($row = mysql_fetch_object($sql))
    	{
        	// Send the emails in this loop.
        	$member_name = $row->displayname;
    	$mailer->AddAddress($row->email);
    
    
        	
            $mailer->Body = str_replace('{MEMBER_NAME}', $member_name, $htmlBody);
            $mailer->IsHTML(true);
            $mailer->AltBody = str_replace('{MEMBER_NAME}', $member_name, $textBody);
    
    
    
        	$mailer->Send();
        	$mailer->ClearAddresses();
        	$mailer->ClearAttachments();
        	$mailer->IsHTML(false);
        	echo "Mail sent to: " . $member_name . "<br />";
    	}
      
      
      
    
      usleep(1000000); // sleep for 1 million micro seconds - will not work with Windows servers / PHP4
      // sleep(1); // sleep for 1 seconds (use with Windows servers / PHP4
      if (1!=1) {
        break;
      }
    }
    
    
    
    ?>
    

     

    I realized it is sending one email by one, so you can add an address without the others seeing one.. :)

  7. So I got further.. mails are sending out, although all the mails are being sent to the first person in the loop, but showing the right names..

     

    <?php
    // Grab our config settings
    require_once($_SERVER['DOCUMENT_ROOT'].'/mail/config.php');
    
    // Grab the FreakMailer class
    require_once($_SERVER['DOCUMENT_ROOT'].'/mail/lib/MailClass.inc');
    
    //set execution time limit to 5 minutes 
    
    $safeMode = ( @ini_get("safe_mode") == 'On' || @ini_get("safe_mode") === 1 ) ? TRUE : FALSE;
    if ( $safeMode === FALSE ) {
      set_time_limit(300); // Sets maximum execution time to 5 minutes (300 seconds)
      // ini_set("max_execution_time", "300"); // this does the same as "set_time_limit(300)"
    }
    
    echo "max_execution_time " . ini_get('max_execution_time') . "<br>";
    
    
    //db connection
    $con = mysql_connect("xxt","xx","xx");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    
    mysql_select_db("xx", $con);
    
    // Setup body
    $textBody = "Dear {MEMBER_NAME},\n\nCheck out PHP Freaks: http://www.phpfreaks.com\n\nSincerely,\nAdmin";
    $htmlBody = "Dear {MEMBER_NAME},<br /><br />Check out PHP Freaks: http://www.phpfreaks.com<br /><br />Sincerely,<br />Admin";
    
    // instantiate the class
    $mailer = new FreakMailer();
    
    // Get the user's Email
    $sql = mysql_query("SELECT displayname,email FROM engine4_users2")or die(mysql_error());
    
    
    //lets reset the time limit of the server everytime an email is sent to bypass maximum
    while (1==1) {
      set_time_limit(30); // sets (or resets) maximum  execution time to 30 seconds)
      // .... put code to process in here
    
    
      		while($row = mysql_fetch_object($sql))
    	{
        	// Send the emails in this loop.
        	$member_name = $row->displayname;
    	$mailer->AddBCC($row->email);
    
        	
            $mailer->Body = str_replace('{MEMBER_NAME}', $member_name, $htmlBody);
            $mailer->IsHTML(true);
            $mailer->AltBody = str_replace('{MEMBER_NAME}', $member_name, $textBody);
    
        	$mailer->Send();
        	$mailer->ClearAddresses();
        	$mailer->ClearAttachments();
        	$mailer->IsHTML(false);
        	echo "Mail sent to: " . $member_name . "<br />";
    	}
      
      
      
    
      usleep(1000000); // sleep for 1 million micro seconds - will not work with Windows servers / PHP4
      // sleep(1); // sleep for 1 seconds (use with Windows servers / PHP4
      if (1!=1) {
        break;
      }
    }
    
    
    
    ?>
    

  8. Haha  ;D but I linked that thread to myself.. he is a bit further behind than I am it seems so looking at that thread doesnt really help..

     

    Like I said I can send single emails but now trying this script for sending to all my emails in the database.. the emails are not being sent, although the script says the emails are successfully sent..

  9. Hi guys,

     

    Wondering if you could guys help me a little bit as I am messing around with PHP mailer, I have this code modified but from here http://www.askapache.com/php/phpfreaks-eric-rosebrocks-phpmailer-tutorial.html

     

    Sending single emails is working fine through PHP mailer, but trying to send to multiple emails from a database is currently not working.. although I am wondering if it is actually doing anything with the emails from the database, I don't want to use $mailer->AddAddress(''); as everyone in the mailing list will see each others email..

     

    The script does succeed and print the names, (edit) but does not send any emails out! At least none get received..(not in spam either) any help? Sorry if this is very obvious!

     

    <?php
    // Grab our config settings
    require_once($_SERVER['DOCUMENT_ROOT'].'/mail/config.php');
    
    // Grab the FreakMailer class
    require_once($_SERVER['DOCUMENT_ROOT'].'/mail/lib/MailClass.inc');
    
    //set execution time limit to 5 minutes 
    
    $safeMode = ( @ini_get("safe_mode") == 'On' || @ini_get("safe_mode") === 1 ) ? TRUE : FALSE;
    if ( $safeMode === FALSE ) {
      set_time_limit(300); // Sets maximum execution time to 5 minutes (300 seconds)
      // ini_set("max_execution_time", "300"); // this does the same as "set_time_limit(300)"
    }
    
    echo "max_execution_time " . ini_get('max_execution_time') . "<br>";
    
    
    //db connection
    $con = mysql_connect("xx","xx","xx");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    
    mysql_select_db("xx", $con);
    
    // Setup body
    $textBody = "Dear {MEMBER_NAME},\n\nTEST";
    $htmlBody = "Dear {MEMBER_NAME},<br /><br />TEST";
    
    // instantiate the class
    $mailer = new FreakMailer();
    
    // Get the user's Email
    $sql = mysql_query("SELECT displayname,email FROM engine4_users2")or die(mysql_error());
    
    
    //lets reset the time limit of the server everytime an email is sent to bypass maximum
    while (1==1) {
      set_time_limit(30); // sets (or resets) maximum  execution time to 30 seconds)
      // .... put code to process in here
    
    
      		while($row = mysql_fetch_object($sql))
    	{
        	// Send the emails in this loop.
        	$member_name = $row->displayname;
    
        	if($row->MailType == 'html')
        	{
            $mailer->Body = str_replace('{MEMBER_NAME}', $member_name, $htmlBody);
            $mailer->IsHTML(true);
            $mailer->AltBody = str_replace('{MEMBER_NAME}', $member_name, $textBody);
        	}
        	else
        	{	
            $mailer->Body = str_replace('{MEMBER_NAME}', $member_name, $textBody);
            $mailer->isHTML(false);
        	}
        	$mailer->Send();
        	$mailer->ClearAddresses();
        	$mailer->ClearAttachments();
        	$mailer->IsHTML(false);
        	echo "Mail sent to: " . $member_name . "<br />";
    	}
      
      
      
    
      usleep(1000000); // sleep for 1 million micro seconds - will not work with Windows servers / PHP4
      // sleep(1); // sleep for 1 seconds (use with Windows servers / PHP4
      if (1!=1) {
        break;
      }
    }
    
    
    
    ?>
    
    

  10. All of this is very easy.. and just get started!

     

    You can have a page to input data into the database

     

    You can have a page to show the data inside the database

     

    You can have a page to edit the data inside the database

     

    To edit the data, all you have to do is get the data from the database by select, output that data inside the right text boxes / areas and have a edit button at the button that links to a script which indeed uses the update function to update the data to the database.

     

    Literally you could write this basic script in a day without any previous knowledge so just start, you have already got the right functions to use, all you need to do now is create the database and write the (simple) script! :)

  11. Hi guys,

     

    I just wanted some input on how to create a system to reset passwords for members, as I have recently learned to use salt and encryption I can not resend the password back to the user, so how would I go about if they lose their password? Reset their password for them automatically and send it to their email by putting in the email which their account is associated to?

     

    I would really appreciate some feedback on this,

     

    Jamie

  12. Function member_sel($id, $value, $identi) {

    $other_sql = mysql_query("SELECT * FROM members WHERE ".$identi." = ".$id." ");

    $member = mysql_fetch_array($other_sql);

    echo $member[$value];

    }

     

     

    member_sel($topic['author'], "username", 'id');

     

    why it is not working ?

    $other_sql = mysql_query("SELECT * FROM members WHERE ".$identi." = ".$id." ")or die(mysql_error());

  13. you create a loop where you pull out the data from your database

     

    <?php
    //get the state from the url
    $state = mysql_real_escape_string($_GET['state']);
    //take data from database where the state is the state from the url
    $result = mysql_query("SELECT * FROM TABLE WHERE state = '$state'");
    //loop so all data is shown
    while($row = mysql_fetch_array($result))
      {
    //show statename
      echo $row['statename'];
      echo "<br>";
      }
    
    ?>
    

  14. Try taking the last comma away?

     

    INSERT INTO HelperFormData (surname, firstname, phone1, phone2, location, qualifications, expertise, assistance, languages, e_mail, consent, published, comments, other_info,) VALUES ('test', 'tesast', 'tesat','tear', 'sest', 'none whatsoever', '', 'ter', 'my language', 'vince@vince.com', 'No', 'No', 'ateaglea', 'ttaelgae')
    

     

    to

     

    INSERT INTO HelperFormData (surname, firstname, phone1, phone2, location, qualifications, expertise, assistance, languages, e_mail, consent, published, comments, other_info) VALUES ('test', 'tesast', 'tesat','tear', 'sest', 'none whatsoever', '', 'ter', 'my language', 'vince@vince.com', 'No', 'No', 'ateaglea', 'ttaelgae')
    

×
×
  • 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.