Sunday, 26 February 2012

PHP form to email explained


PHP form to email explained

It is a common requirement to have a form on almost any web site.
In this article, we will create a PHP script that will send an email when a web form is submitted.
There are two parts for the web form:
  1. The HTML form code for the form. The HTML code below displays a standard form in the web browser. If you are new to HTML coding, please see: HTML form tutorial
  2. The PHP script for handling the form submission. The script receives the form submission and sends an email.

HTML code for the email form:
<form method="post" name="myemailform" action="form-to-email.php">
Enter Name: <input type="text" name="name">
Enter Email Address:    <input type="text" name="email">
Enter Message:  <textarea name="message"></textarea>
<input type="submit" value="Send Form">
</form>
The form contains the following fields:
name, email and message.
name and email are single-line text input fields where as message is a text area field (multi-line text input).
You can have different types of input fields in a form. Please see the HTML form input examples page for details.
On hitting the submit button, the form will be submitted to "form-to-email.php". This form is submitted through the POST method

Accessing the form submission data in the PHP script

Once your website visitor has submitted the form, the browser sends the form submission data to the script mentioned in the 'action' attribute of the form. (for the current form, the script is form-to-email.php)
Since we have the form submission method mentioned as POST in the form (method='post') we can access the form submission data through the $_POST[] array in the PHP script.
The following code gets the values submitted for the fields: name, email and message.
<?php
  $name $_POST['name'];
  $visitor_email $_POST['email'];
  $message $_POST['message'];
?>

Composing the email message

Now, we can use the above PHP variables to compose an email message. Here is the code:
<?php
    $email_from 'yourname@yourwebsite.com';
    $email_subject "New Form submission";
    $email_body "You have received a new message from the user $name.\n".
                            "Here is the message:\n $message".
?>
The 'From' address, the subject and the body of the email message are composed in the code above. Note the way the body of the message is composed using the variables.
If a visitor 'Anthony' submits the form, the email message will look like this:

"You have received a new message from the user Anthony.
Here is the message:
Hi,
Thanks for your great site. I love your site. Thanks and Bye.
Anthony."

Sending the email

The PHP function to send email is mail().
mail(to,subject,message,headers)
For more details, see the PHP mail() page.
The headers parameter is to provide additional mail parameters ( like the from address, CC, BCC etc)
Here is the code to send the email:
<?php
  $to "yourname@yourwebsite.com";
  $headers "From: $email_from \r\n";
  $headers .= "Reply-To: $visitor_email \r\n";
  mail($to,$email_subject,$email_body,$headers);
 ?>
Notice that we put your email address in the 'From' parameter and the visitor's email address in the 'Reply-To' parameter. The 'From' parameter should indicate the origin of the email. If you put the visitor's email address in the 'From' parameter, some email servers might reject the email thinking that you are impersonating someone.

Sending the email to more than one recipients

If you want to send the email to more than one recipients, then you just need to add these in the "$to" variable.
<?php
  $to "name1@website-name.com, name2@website-name.com,name3@website-name.com";
  mail($to,$email_subject,$email_body,$headers);
?>
You can use the CC (carbon copy) and BCC (Blind Carbon Copy) parameters as well. The CC and BCC emails are added in the 'headers' parameter.
Sample code:
<?php
$to "name1@website-name.com, name2@website-name.com,name3@website-name.com";
$headers "From: $email_from \r\n";
$headers .= "Reply-To: $visitor_email \r\n";
$headers .= "Cc: someone@domain.com \r\n";
$headers .= "Bcc: someoneelse@domain.com \r\n";
mail($to,$email_subject,$email_body,$headers);
?>

Securing the form against email injection

Spammers are looking for exploitable email forms to send spam emails. They use the form handler script as a 'relay'. What they do is to submit the form with manipulated form values. To secure our form from such attacks, we need to validate the submitted form data.
All the values that go in the 'headers' parameter should be checked to see whether it contains \r or \n. The hackers insert these characters and add their own code to fool the function.
Here is the updated code:
<?php
function IsInjected($str)
{
    $injections array('(\n+)',
           '(\r+)',
           '(\t+)',
           '(%0A+)',
           '(%0D+)',
           '(%08+)',
           '(%09+)'
           );
    $inject = join('|'$injections);
    $inject "/$inject/i";
    if(preg_match($inject,$str))
    {
      return true;
    }
    else
    {
      return false;
    }
}
if(IsInjected($visitor_email))
{
    echo "Bad email value!";
    exit;
}
?>
In general, any value used in the header should be validated using the code above.
Better, complete validations could be done using the PHP form validation script here.

PHP form to email complete code

The link below contains the complete form, validation and emailing code.

Thursday, 16 February 2012

GATE - 2012 Question Papers & Answer Keys


GATE - 2012 Question Papers & Answer Keys

Opportunities After B.E/B.Tech


Opportunities After B.E/B.Tech

The last decade has seen a tremendous change in the attitude of people towards their careers. Gone are the days when the only choices we had after completing school were Engineering, Medicine, Chartered Accountant, B.Com, and Law besides a few others. Today’s generation has endless career options open in front of it (from Nuclear Scientist to DJ). However, this presentation certainly is helping hand to decide your career after B.Tech

Introduction:

Before we go any further and talk about Career Planning, let’s just look at the change in the job scenario in the last decade:

• Growth of service sector, especially IT. In spite of the recent recession in the US economy, IT has been growing at an explosive rate with the requirement for skilled manpower in this sector desperately falling short of demand. As a result, countries that face such a shortage are busy recruiting manpower (on work permits) from countries, which have an adequate supply.

• In this era of global village, a person today is a global citizen going and living where his/her career aspirations take him/her. One’s country of birth is no longer the default choice to pursue a career in. Thus, we have people born in one corner of the world migrating and pursuing successful careers in another part of the world.

• Knowledge about Information, Communication and Entertainment, commonly referred to as the ICE Age has become increasingly important, rather inevitable for the students, specifically with the onset of IT.

• The focus today is on acquiring multiple skills and cross functionality rather than specializations: Today organizations are not made up of different departments each of them having a focused task and a limited role; instead today they are made up of teams. These teams consist of people who although have specialized skills but have to synergize their efforts in achieving a common goal.

• Liberalization, Privatization and Globalization (LPG) are also opening new opportunities for different people. Procedures like deli censing encourage entrepreneurial activity, which leads to a lot more people taking initiative and exploiting their talents to their fullest potential. It is astonishing how many 21-year-old millionaires exist today and it is anybody’s guess how many more are expected tomorrow.

• Increasing presence of women in the working force plus increasing presence of women in areas traditionally considered male bastions for e.g. the armed forces.

• As the standard of living is increasing throughout the world; people are moving away from pure monetary considerations while considering a career. True, monetary considerations are still very important, but the weight age of other factors like emotional satisfaction, spiritual fulfillment etc. is increasing. Furthermore acceptance of these factors in a career decision is universally increasing and today a parent is more considerate and open, if his/her teenager states the desire to become a DJ, instead of a Chartered Accountant.

• Increase in pay packages plus increase in working hours but with increased flexibility.

• It has been propounded by most of the management gurus that emphasis of the next decade would shift from design and technology to happiness and aesthetics, clearly indicating the trend that one's job should match one's potential and interest rather than be decided on one's whims and fancies and dictates of peers and the available norms. Consequently there has been increased job/career switching for various reasons ranging from growth prospects to personal factors like need for creativity etc.

What does it all mean and where does it lead?

Simply put, with so much happening so quickly, most of us do not know what to do. Taking the information mentioned above into consideration and other factors like Parental Pressure, Peer Pressure, Environmental and Social Norms, the issue (i.e. your career decision) gets all the more complicated.
Another very crucial need also exists and that is an opportunity to identify and then develop those traits of your personality, which with respect to today’s scenario is absolutely necessary irrespective of one’s profession. Some of these traits are the ability to work in teams, leadership, creativity, communication skills etc.

This simply means that there is definitely a need for one to go through a process, which will not only enlighten and inform the individual with respect to the various career options, but will also be a journey of discovery of one’s own Interests, Aptitude and Personality which are the very critical components of any career decision. Added to this, one also needs to identify areas of personal development and needs to work on them before embarking on his/her career roadmap.

So, it is necessary for one to decide their career. Now that you have entered into B.Tech. So, now you have to start looking into your future.

Study or Job ?

There are two options you prefer after you complete your B.Tech degree. If you are economically efficient and don’t need a job, it is better you go for your further studies. A specialization will always earn you more salary as well as priority during interviews and of course sound grip over subject. Otherwise you can find some job.

Further Studies:

If you prefer to continue to studies, you can do Post graduate courses and then obtain a Ph.D. You have lots of options during this P.G course like M.S/ M.Tech, IAS/IPS, Navy/NDA and Finance related courses like MBA.

M.S/M.Tech:

If you prefer doing P.G in your field of study, you can go for M.S/M.Tech. If you are ready to go outside India and financially sound you can prefer M.S. You need to appear for GRE/TOEFL for doing M.S in Foreign countries.

GRE: The Graduate Record Examination or GRE is a standardized test that is an admissions requirement for many graduate schools in English speaking countries. It is created and administered by the Educational Testing Service and is similar in format and content to the SAT. It is a computer based Online Test. The percentile scored in this exam will decide your future in doing M.S in foreign nations

TOEFL: The Test of English as a Foreign Language (or TOEFL®, pronounced "toe-full" or sometimes "toffle") evaluates the potential success of an individual to use and understand Standard American English at a college level. It is required for non-native applicants at many English-speaking colleges and universities. A TOEFL score is valid for two years and then is deleted from the official database.

The TOEFL® test is a registered trademark of Educational Testing Service (ETS®) and is administered worldwide. The test was first administered 1964 and has since been taken by nearly 20 million students.

Since its introduction in late 2005, the Internet-based test (iBT) has progressively replaced both the computer-based (CBT) and paper-based (PBT) tests. The iBT has been introduced in phases, with the United States, Canada, France, Germany, and Italy in 2005 and the rest of the world in 2006, with test centers added regularly.

The demand for test seats remains very high even after almost a year after the introduction of the test: Candidates have to wait for months since short-term test dates are fully booked. The four-hour test consists of four sections, each measuring mainly one of the basic language skills (although some tasks may require multiple skills) and focusing on language used in an academic, higher-education environment. Note-taking is allowed in the iBT.

GATE: Conducted by one of seven Indian Institutes of Technology in rotation, Graduate Aptitude Test in Engineering (GATE) is an annual exam for admission to M.Tech and M.S. programmes in most engineering institutes in India[citation needed]. It is regarded as a benchmark test for engineering graduates in India [citation needed]. This examination is coordinated by a committee, comprising of Indian Institute of Science, Bangalore and seven Indian Institutes of Technology on behalf of the National Coordinating Board - GATE, Department of Education, and Government of India. The pattern and syllabus are usually based on a candidate's B.Tech. Or BE syllabus. Minimum eligibility for appearing in this exam is usually a B.Tech, BE, B. Arch. or Masc. The exam is usually conducted on second Sunday of February.

PSU's like BARC, NPCIL, HAL etc. give importance to GATE scores for various job positions in their organizations.

It is not worthy for anyone doing P.G in some college other than Foreign/Indian University Colleges, and Premiere Private Engineering Colleges

MBA:

If you prefer doing P.G in some finance related courses you can definitely go for MBA.

GMAT: The Graduate Management Admissions Test, better known by the acronym GMAT (pronounced G-mat), is a standardized test for determining aptitude to succeed academically in graduate business studies. The GMAT is used as one of the selection criteria by most respected business schools globally, most commonly for admission into an MBA program.

The GMAT is one of many factors schools use when reviewing applications for admission; it is typically balanced with work experience, grades in previous schools, recommendation letters and other admissions criteria.

The fee to take the GMAT is currently US$250, worldwide.

Global institutes like ISB require the entries to write GMAT.

CAT: Common Admission Test is conducted by IIMs in India for entry to various IIMs present in India. Admissions are based on the scores in CAT exam.

Indian Civil Service:

The Indian Civil Service serves as the backbone of India and carries great respect and responsibilities. India's best brains vie for entry into the Indian Civil Services as officers. Even though corporate jobs may offer the best of salaries and perks, a majority of youngsters and their parents still crave entry to the prestigious Indian Civil Services held by the UPSC. The very fact that a big share of every year's top posts in the civil services exams are bagged by professionals from various streams, shows that the IAS is still the dream job for many

These are most preferred routes by engineering students in education after B.Tech

Job/ work:

Software industry:

What ever the branch you are in during your engineering you can get into a software industry with simply communication skills. It is good if you get a job during the campus placements itself because it is really difficult to find a job after you come out of the college. However there are various kinds of jobs in Software industry which you get accordingly as your course of study or your specialization. It is ok if you do job for sometime and start studying again for your P.G courses.

Own Company:

If you are financially sound, you can start your own company with a little experience in some other company.

Still there are various choices in jobs like lecturer in some famous engineering college, call center jobs, etc.

Conclusion:

So decide your career now it self and prepare accordingly to reach your goal.








WEB TECHNOLOGIES Objective Exam


Code No: A107321201 Set No. 1
JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD
III B.Tech. II Sem., I Mid-Term Examinations, February– 2011
WEB TECHNOLOGIES
Objective Exam
Name: ______________________________ Hall Ticket No.
Answer All Questions. All Questions Carry Equal Marks.Time: 20 Min. Marks: 20.
A
I Choose the correct alternative:
1. The HTML tag used to include ready - formatted text on a web page is [ ]
(a) < br > (b) < amp > (c) < gre > (d) < pre >
2. What is the tag used to embed the multimedia objects directly into the webpage? [ ]
(a) href (b) include (c) link (d) object
3. __________ is the process of ensuring that some data might be correct data for a particular application. [ ]
(a) Data validation (b) Data correction (c) Data checking (d) Data deletion
4. ________ calls a function when the cursor moves away from the image. [ ]
(a) onmouserover (b) onload (c) onmouseout (d) onsubmit
5. A Java Bean may be _______ to an end user. [ ]
(a) visible (b) invisible (c) transparent (d) visible or invisible
6. ___________calls a javascript function when the cursor passes the over the image. [ ]
(a) onsubmit (b) onmouserover (c) onload (d) onmouseout
7. In forms to retrieve information from a server we use [ ]
(a) get (b) put (c) post (d) paste
8. To transform one data structure into another __________ is used. [ ]
(a) XML (b) DHTML (c) HTML (d) XSL
9. The variable names in JavaScript can begin with [ ]
(a) dollar( $ ) (b) underscore( _ ) (c) minus( - ) (d) carot( ^ )
10. A Bean is a Java Beans [ ]
(a) interface (b) class (c) component (d) object

Code No: A107321201 :2: Set No.1
II Fill in the blanks:
11. In XML document, the data type of the element must be preceded by a ____________symbol.
12. In JavaScript, variables are declared using the keyword ______________
13. In XML, the element tag starts with ______________
14. The introspection mechanism finds all of the__________ methods of a bean.
15. A _____________ is a way of keeping the names used by applications separate from each other.
16. The HTML tag used to include ready - formatted text on a web page is ____________.
17. ________ attribute of a frame tag works like an image source or a hyperlink address.
18. ________ are used to add an element of interactivity to a website.
19. ____________ is used to describe the structure of a document not the way that it is presented.
20. __________ is a combination of content formatted using HTML, cascading style sheets, a scripting language and the DOM.
-oOo-


Code No: A107321201 Set No. 1
WEB TECHNOLOGIES
KEYS
I Choose the correct alternative
1. d
2. d
3. a
4. c
5. d
6. b
7. a
8. d
9. b
10. c
II Fill in the blanks:
11. #
12. Var
13. Exclamation mark
14. Public
15. Namespace
16. <pre>
17. src
18. Forms
19. XML
20. Dynamic HTML


JNTU Mid I


Use Download Link-1 or Download Link-2 to get the Mid Time Tables
2-2 B.Tech (R09) - I Mid Time TablesDownload Link-1Download Link-2
3-2 B.Tech (R09) - I Mid Time TablesDownload Link-1Download Link-2
4-2 B.Tech (R07) - I Mid Time TablesDownload Link-1Download Link-2
2-2,3-2,4-2 B.Pharmacy (R09) - I Mid Time TablesDownload Link-1Download Link-2

New U.K. restrictions on work after study


New U.K. restrictions on work after study

From April, foreign students from non-European Union countries will be required to have a firm job offer of a minimum £20,000 a year from a government-approved employer if they wish to stay on in Britain after completing their studies, the government announced on Tuesday, piling agony on non-EU students already groaning under a raft of new restrictions which have led to a drop in Indian student numbers.

Under the current rules, students can work in Britain for two years after finishing their course but the government claims that the system is being abused with people using student visas to enter the country and then dropping out of their studies to look for employment.

The Conservative Immigration Minister, Damian Green said in the past “too many students have come to the U.K. to work rather than study and this abuse must end”.

“It is vital that we continue to attract the brightest and the best international students but we have to be more selective about who can come here and how long they can stay,” he said.

In a statement, the Home Office said that from April 6, “a more selective system” would come into effect so that “only the most talented international graduates can apply to stay in the U.K. for work purposes”.

“That means only those graduating from a university, and having a job offer from a reputable employer accredited by the U.K. Border Agency at a salary of £20,000 or more, will be able to continue living and working in the U.K. in order to benefit the British economy,” it said.

To boost the economy, student entrepreneurs with at least “£50,000 to invest in their business” will also be allowed to stay on and work after their studies.

Under a new “Graduate Entrepreneur” scheme, up to 1,000 university places will be available for students “working on world-class innovative ideas who want to stay and develop them but do not meet the requirements of the Tier 1 (Entrepreneur) route”.

The new rules are part of a government crackdown on non-EU immigration to fulfill the Conservative Party's election pledge to drastically cut down immigration-levels. The issue has caused tensions within the ruling coalition with the Liberal Democrats opposed to what they regard as a xenophobic approach to immigration.

Businesses and universities have warned that too many restrictions would drive away international talent and ultimately hurt the economy. Non-EU students contribute nearly £8 billion to British economy every year, an estimated £6 billion in fee alone.

“This scheme is more restrictive than the old post-study work route and we are concerned that some Russell Group courses have already seen a drop of 30 per cent from India,” Wendy Piatt, director-general of the Russell Group of 20 top universities that include Oxford and Cambridge, told The Financial Times.

Source : Hindu

Private colleges refuse refund


Private colleges refuse refund

Engineering and other professional colleges in the state are refusing to refund fees and return original certificates in case students cancel their admissions later. The All India Council for Technical Education (AICTE) has received several complaints from students against colleges for harassing them to pay the entire course fee even if they cancel the admission later. Students complained that the managements were holding back their original certificates saying that they will be returned only if they pay the entire fee, which is in violation of the rules.

AICTE issued a public notice in June 2009, saying that in the event of a student withdrawing before the start of the course, the fee collected from the student minus a processing fee of not more than `1,000, must be refunded to the student. AICTE also said that if a student leaves after joining the course, and the seat is filled by another candidate before the last date of admission, the institution must return the fee collected with proportionate deductions of monthly fee and hostel rent, wherever applicable. It also warned institutions that any violation of these instructions will invite punitive action, including withdrawal of approval and recognition of the erring institutions.

Students can complain to AICTE or the UGC, which has issued more or less similar instructions on fee refund. If even after that they fail to get the refund, they can seek redress before the court. With no common academic calendar followed by professional colleges, many students are forced to pay the fees and hand over the original certificates.

Source : DC