Jump to content

buntus00

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

buntus00's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. If you are using XAMPP, you might have problems sending. Your ISP may want to know who is sending through their servers. It should be a lot easier if you upload your proposed script to your ISP's server. I had problems sending through XAMPP. As soon as I uploaded my script, everything worked seamlessly. So....anyway, If, for example, you had a form and wanted to send mail through it, you would first define the email address variable. e.g. $email_address = addslashes(strip_tags($_POST['email_address'])); Then define the FROM: address to give the http headers information to the server. <?php //send activation email $to = $email_address . ', ' ; $subject = "Activate your account"; $headers = "From: john.tobin1@gmail.com"; $body = "Welcome $user_name, Put the body of the email here"; ?> The vital step to actually send through gmail is to edit a file called php.ini If you have a web site, you will just need to download that file from your ISP's root directory, and modify it, telling it which SMTP server should be used to send to send mail. If your site is with Godaddy, then it would be Godaddy's SMTP server. (NOT gmail's) For example in their case it would be relay-hosting.secureserver.net So in the php.ini file, just look for the corresponding SMTP line in the script. If the file explicitly asks for a port number it should be 25. [mail function] ; For Win32 only. SMTP = relay-hosting.secureserver.net smtp_port = 25 Below is a sample Godaddy php.ini which they have stripped down to a minimum of essential functions that they want. 'register_globals' should be = off register_globals = off allow_url_fopen = off expose_php = Off max_input_time = 60 variables_order = "EGPCS" extension_dir = ./ upload_tmp_dir = /tmp precision = 12 SMTP = relay-hosting.secureserver.net url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=,fieldset=" [Zend] zend_extension=/usr/local/zo/ZendExtensionManager.so zend_extension=/usr/local/zo/4_3/ZendOptimizer.so This should do it for you.
  2. Thanks for the reply. I work hard before I come here. I was looking for a concrete way, to implement nl2br or any other comparable solution. I'm happy for any help I can get. If you can't answer my question, that's cool, too. 'Not a single question can not be answered by looking in the documentation' You realize you just negated the reason for the very existence of this forum, right?
  3. I'm a newbie to php and have a volunteer project to create a jobs board. It works on the same principle as a guest book where you would add comments, except you post jobs. However, I have a formatting problem with textarea boxes. People who post jobs need a minimum of styling, e.g. bullets, bold etc. Before I go into that, the ultimate solution would be to incorporate a text editor into the php that could handle multiple textarea boxes. I've reviewed a few, TinyMCE, fck editor, etc, but they are javascript-based, (I don't know js) -and full detailed and accurate instructions on how to incorporate these with php are scant. If anyone knows of a piece of freeware that would do the trick, please advise with clear instructions, but, -it has to be easy. Ok, Formatting issue: New line breaks are not recognised by the textarea when the Enter key is pressed. e.g. If I add bullets to the textarea, (by adding ASCII characters = &#149; -essential for job descriptions) then press enter at the end of the line, -yes, each bullet shows on a new line within a textarea before posting, but... after posting, when the info is pulled from of the db again and displayed via body.html, it appears just as a long string. I've included here just the stripped-down code relevant to the issue. What have I tried? Experiments with a wrap ="hard" attribute within the form, I've tried nl2br but don't know with precision how and where to implement it so it works. I just tried it in the posting file (postjob.php) That ain't working. Also I just don't know how two apparently conflicting concepts can be resolved. On the one hand, I understand I need to prevent people inserting raw html into the db -and I had previously used stripslashes for that (plus mysql_real_escape_string against SQL injection) and on the other hand, I need to be able to put line breaks in there, (and I understand nl2br converts to a <br /> anyway). But we shouldn't have html in there anyway, right? I don't get it. I also have a job editing section (a form), where people can pull up and edit their jobs. When I pull up sample jobs from the db, using $_GET. -again it's all visually on one line plus it's peppered with horrible <br> tags that job owners should not be seeing. This form is presumably only pulling out of the db what is already in there, so the <br> tags are getting in there. Any help on this from anyone, it's driving me nuts. (But please don't refer me to php.net, -it's an esoteric quagmire for beginnners.) Thanks! ------------------------------------------------------------ Sample code: How it works Postform.php = job posting form <div style = margin-left:101px;> <br /> <strong>Detailed description:</strong> <br /> <textarea name ="job_description" rows="5" cols="95" wrap ="hard" ></textarea> <br /> <br /> <strong>Required skills: </strong> <br /> <textarea name ="required_skills" rows="5" cols="95" wrap ="hard"> </textarea> <br /> <br /> <strong>Application instructions:</strong> <br /> <textarea name="job_app_instructions" rows="4" cols="95" wrap ="hard"></textarea> </div> ________________________________________________________ Postjob.php = posts the jobs //Standard input boxes $job_title= mysql_real_escape_string($_POST['job_title']); $job_number = mysql_real_escape_string($_POST['job_number']); $pay_rate= mysql_real_escape_string($_POST['pay_rate']); //Textarea input boxes $job_description= nl2br($_POST['job_description']); $required_skills= nl2br($_POST['required_skills']); $job_app_instructions= nl2br($_POST['job_app_instructions']); ________________________________________________________ body.html = pulls jobs from db (job display page) $get= mysql_query ("SELECT * FROM posted_jobs ORDER BY ID "); while($row = mysql_fetch_array($get)) { $job_title= $row ['job_title']; $job_number= $row ['job_number']; $job_type= $row ['job_type']; $pay_rate = $row ['pay_rate']; $job_location = $row ['job_location']; $date_posted = $row ['date_posted']; $job_description= $row ['job_description']; $required_skills= $row ['required_skills']; $job_app_instructions= $row ['job_app_instructions']; $add_notes= $row ['add_notes']; echo " <hr> .<br /> <strong> $job_title </strong><br /><br /><br /> <strong>Job number: $job_number </strong><br /> <strong>Job type: $job_type</strong> <br /> <strong>Pay rate: $pay_rate</strong> <br /> <strong>Location: $job_location </strong> <br /> <strong>Date posted: $date_posted </strong><br /> <br /> <strong>Job description: </strong> <br /> $job_description <br /> <br /> <strong>Job requirements: </strong> <br /> $required_skills <br /> <br /> <strong>Application instructions: </strong> <br /> $job_app_instructions </strong> <br /> <br />"; if (empty($row ['add_notes'])) { } else echo "<strong>Additional notes: </strong> <br /> $add_notes <br /> <br />";
  4. Thanks for that. However, I understand that rewind($fp); should work. Am I mistaken? I had tried a different switch earlier (r+) and that did write to the start of the file, perfectly, (but that just over-writes the topmost file unfortunately). In your sample script, I understand everything except the $output = <<<HTML and then: $contents; HTML; part. I don't get it. Sorry, I'm a beginner. Do you mean that content /text should go there? Could you explain what's going on there? I mean, you don't mean HTML should be a variable or anything, do you? Also, how would 'file_get_contents' work in this context- bearing in mind there are 3 files involved. File 1: postform.html, that writes to postjob.php which writes the posted data to jobs.html So the data is processed by file 2 and heads straight to file 3. Any help is appreciated.
  5. I have a working script here in a php file that receives data from a simple form and posts it to a 3rd html file. The script works. As I've toldphp to open the file in 'append' mode, each time data is posted it appends the data, rather than over-writing it, which is what I want, So that works, but I need it to write new data on top. I found a php entity for the job, called 'rewind' which is supposed to set the file pointer to the beginning of the file, so data is written there. Alas, to my perplexity, data is still being appended to the bottom instead of the top. Anyone able to see what's wrong or missing from this simplified snippet? Syntax errors? What have I failed to supply? Thanks. <?php $filename = "jobs/body.html"; $field1="<pre><p><h3>Job Number: "; $field2="<h3>Job title: "; $fp = fopen ($filename, 'a+'); $size = filesize($fn); $hr = "<hr>"; $space = "<br />\r\n"; if ($fp) { rewind($fp); fwrite ($fp, $field1); if($_POST['jobnumber']) fwrite($fp, stripslashes($_POST['jobnumber'])); fwrite ($fp, $field2); if($_POST['jobtitle']) fwrite($fp, stripslashes($_POST['jobtitle'])); fwrite ($fp, $hr); fclose ($fp); echo ("<b>File written successfully!</b>"); } else { echo ("<b>File was not written</b>"); } ?> EDIT: please use code tags next time -zanus
  6. Hi, lmao. Thanks. As I said, I'm a beginner, but I did manage to resolve this, as I had already working along certain lines. I wasn't familiar with the implementation of the 'foreach' solution you mentioned and you didn't explain. I will check that out though, for a more elegant solution. What I have is doubtless not exactly pretty or elegant, but nevertheless did the trick, until I get to the next level. This writes directly to the 3rd and last file in the series. I also had a problem with apostrophes appearing in the text as "\" then I discovered the 'striplashes' solution implemented below. buntus00. <?php $filename = "jobs/body.html"; $field1="<h3>Job Number:"; $field2="<h3>Job title:"; $fp = fopen ($filename, "a+"); $size = filesize($fn); if ($fp) { fwrite ($fp, $field1); if($_POST['jobnumber']) fwrite($fp, stripslashes($_POST['jobnumber'])); fwrite ($fp, $field2); if($_POST['jobtitle']) fwrite($fp, stripslashes($_POST['jobtitle'])); fclose ($fp); } ?>
  7. Thanks for that, Russell. Unfortunately it hasn't worked. If I can be clear. The problem is the names of the field titles (in spite of how I expressed it in the subject line). I can get them to echo to file2. The problem is that they don't make it over to file 3. That's the bummer. Thanks for trying, though. I appreciate it.
  8. Hi, I'm a php newbie. I've looked everywhere for a solution. This is killing me. The idea is to write form data to a file without using a database (flat file database model) I'm using 3 files: File 1 (html form) writes to file 2 (php), and file 2 writes to a 3rd file -an html file (not a .txt file). Problem: While the form works -the raw info from the fields shows up .... but the field names won't. I'm using fwrite to do it. Doubtless the code is bad. But I don't know the code that will do it. Looked into arrays and stuff, but that's beyond where I am right now. Any help would be appreciated. File 1: jobform.html <form action="postjob.php" method="post"> Job title: <input type="text" name="jobtitle"> Job Type: <input type="text" name="jobdescription"> <input type="submit" value="Send"> </form> --------------------------------------------------------------------- File 2: postjob.php <?php $fn = "jobs/body.html"; $file = fopen($fn, "a+"); $size = filesize($fn); $space = "<br />\r\n"; if($_POST['jobtitle']) fwrite($file, $_POST['jobtitle']); if($_POST['jobdescription']) fwrite($file, $_POST['jobdescription']); $text = fread($file, $size); fwrite ($file, $space); fwrite ($file, ""); fclose($file); ?>
×
×
  • 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.