loveranger Posted July 17, 2009 Share Posted July 17, 2009 OK, I've got a simple application form. Look below: http://www.rnkprofessionalcorporation.com/website/application.htm Once someone clicks submit, how do I make it send me all those information in a well organized format? To a file on my server or e-mail? What would I have to be the code in the process.php? Quote Link to comment https://forums.phpfreaks.com/topic/166343-need-help-with-simple-application-form/ Share on other sites More sharing options...
quasiman Posted July 17, 2009 Share Posted July 17, 2009 in a well organized format? To a file on my server or e-mail? I think this is the first thing you have to decide. How do you want the data? From there, a super simplified mail script looks like this <?php $body = $_POST['First_name'] ."<br>"; $body .= $_POST['Last_name'] ."<br>"; mail($to, $subject, $body, $headers) ?> Again yours to decide what the variables contain. Or as saving a file to your server <?php $file = fopen("test.txt","w"); $body = $_POST['First_name'] ."<br>"; $body .= $_POST['Last_name'] ."<br>"; echo fwrite($file,$body); fclose($file); ?> That said, you really shouldn't overpost your questions Quote Link to comment https://forums.phpfreaks.com/topic/166343-need-help-with-simple-application-form/#findComment-877174 Share on other sites More sharing options...
loveranger Posted July 17, 2009 Author Share Posted July 17, 2009 Thanks... That looks like the exact code I'm looking for except a few conditions.... For each new application it is overwriting into test.txt. How would I have it make new .txt files for each new application? Also this is what I'm getting as output.... John<br>Smith<br> It's not using <br> properly... how to fix this? Quote Link to comment https://forums.phpfreaks.com/topic/166343-need-help-with-simple-application-form/#findComment-877296 Share on other sites More sharing options...
loveranger Posted July 20, 2009 Author Share Posted July 20, 2009 please help... Quote Link to comment https://forums.phpfreaks.com/topic/166343-need-help-with-simple-application-form/#findComment-878699 Share on other sites More sharing options...
elis Posted July 20, 2009 Share Posted July 20, 2009 You need to tell the script to change the name of the text file each time it runs. The simplest way would be to generate a random name and append it to the file. i.e. <?php //Create a random 10-digit alphanumeric variable function randomgen() { $length = 10; $string = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $key = substr( str_shuffle($string), 0, $length ); return $key; } $filename = randomgen(); $file = fopen("$filename.txt","w"); $body = $_POST['First_name'] ."<br>"; $body .= $_POST['Last_name'] ."<br>"; echo fwrite($file,$body); fclose($file); ?> Regarding "John<br>Smith<br>" You've created a text file, it is not able to print in HTML. You would need to change the file extension, or change how you're inputting data into test.txt Quote Link to comment https://forums.phpfreaks.com/topic/166343-need-help-with-simple-application-form/#findComment-878762 Share on other sites More sharing options...
loveranger Posted July 24, 2009 Author Share Posted July 24, 2009 thanks. instead of putting it as random number, how can i make it create a new file for each new application numerically. 1.txt 2.txt 3.txt ...etc Quote Link to comment https://forums.phpfreaks.com/topic/166343-need-help-with-simple-application-form/#findComment-881674 Share on other sites More sharing options...
loveranger Posted July 24, 2009 Author Share Posted July 24, 2009 Also how can I make the script put the time and date of when the file was created.....any help would be greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/166343-need-help-with-simple-application-form/#findComment-881675 Share on other sites More sharing options...
loveranger Posted July 24, 2009 Author Share Posted July 24, 2009 I am trying to make it display like such...... First name: Joe Last name: Smith with the code... <?php //Create a random 10-digit alphanumeric variable function randomgen() { $length = 10; $string = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $key = substr( str_shuffle($string), 0, $length ); return $key; } $filename = randomgen(); $file = fopen("$filename.html","w"); $body = ."<b>First name</b>" $_POST['First_name'] ."<br>"; $body .= ."<b>First name</b>" $_POST['Last_name'] ."<br>"; echo fwrite($file,$body); fclose($file); ?> What's wrong? I'm getting this error... Parse error: syntax error, unexpected '.' in /home/adfinanc/public_html/process.php on line 14 Quote Link to comment https://forums.phpfreaks.com/topic/166343-need-help-with-simple-application-form/#findComment-881677 Share on other sites More sharing options...
seventheyejosh Posted July 24, 2009 Share Posted July 24, 2009 make $body = ."<b>First name</b>" $_POST['First_name'] ."<br>"; $body .= ."<b>First name</b>" $_POST['Last_name'] ."<br>"; into $body="<b>First name</b> ".$_POST['First_name']."<br>"; $body.="<b>Last name</b> ".$_POST['Last_name']."<br>"; lemme know Quote Link to comment https://forums.phpfreaks.com/topic/166343-need-help-with-simple-application-form/#findComment-881683 Share on other sites More sharing options...
loveranger Posted July 24, 2009 Author Share Posted July 24, 2009 thank you so much... now i just need to know how to make new application file name numerically instead of random generator. Quote Link to comment https://forums.phpfreaks.com/topic/166343-need-help-with-simple-application-form/#findComment-882397 Share on other sites More sharing options...
vineld Posted July 24, 2009 Share Posted July 24, 2009 In order to make the text files appear in numeric order you need to know the next number which means you need to store the value somewhere. The easiest way is to simply write the number to a text file each time. Then you just read the number and add 1 to it every time a new e-mail is sent. You could also store it in the database if that seems easier. Another way would be to check which text files exist already and get next number that way but that means unnecessary work. Also, always be on the lookout for mail injections when sending e-mails with form data. Quote Link to comment https://forums.phpfreaks.com/topic/166343-need-help-with-simple-application-form/#findComment-882401 Share on other sites More sharing options...
loveranger Posted July 24, 2009 Author Share Posted July 24, 2009 I'm pretty sure there is a code that automatically renames each new application numberically... Quote Link to comment https://forums.phpfreaks.com/topic/166343-need-help-with-simple-application-form/#findComment-882405 Share on other sites More sharing options...
vineld Posted July 25, 2009 Share Posted July 25, 2009 Yeah, the method do so was what I described above. Quote Link to comment https://forums.phpfreaks.com/topic/166343-need-help-with-simple-application-form/#findComment-882408 Share on other sites More sharing options...
loveranger Posted July 25, 2009 Author Share Posted July 25, 2009 Can you provide the code? :-\ Quote Link to comment https://forums.phpfreaks.com/topic/166343-need-help-with-simple-application-form/#findComment-882426 Share on other sites More sharing options...
loveranger Posted July 25, 2009 Author Share Posted July 25, 2009 Hey.... this is my last question. Please help me out. For the output, I want to display like this: First name: John Last Name: Smith Address: 12 Cherry street ave City: London Province: Ontario Postal Code: A1B 2C3 I've tried to make a code but it keeps displaying error.... I want the column of Last Name, City, Postal Code, etc. all to be aligned perfectly. Is this possible? How will the code look like in process.php? Quote Link to comment https://forums.phpfreaks.com/topic/166343-need-help-with-simple-application-form/#findComment-882835 Share on other sites More sharing options...
lonewolf217 Posted July 25, 2009 Share Posted July 25, 2009 you may want to use css for this and use defined widths to make the columns lined up this is what you would be doing on a very basic level .columns { float:left; width:200px; } <div class="columns"> <?php echo "first name"; echo "address"; echo "province"; ?> </div> <div class="columns"> <?php echo "last name"; echo "city"; echo "postal code"; ?> </div> Quote Link to comment https://forums.phpfreaks.com/topic/166343-need-help-with-simple-application-form/#findComment-882838 Share on other sites More sharing options...
loveranger Posted July 25, 2009 Author Share Posted July 25, 2009 <?php //Create a random 10-digit alphanumeric variable function randomgen() { $length = 10; $string = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $key = substr( str_shuffle($string), 0, $length ); return $key; } $filename = randomgen(); $file = fopen("$filename.html","w"); $body="<table border="0" width="502" height="50" id="table1"> <tr> <td height="46" width="240"> <font face="Verdana" size="2">First name: </font><font face="Verdana"><font size="2"> </font>".$_POST['First_name']."<font size="2"> <br>Address: </font><font style="font-size: 5pt"> </font>" .$_POST['Address']."</td> <td height="46" width="246"> <font face="Verdana"> <font size="2">Last Name: </font>".$_POST['Last_name']."<font size="2"> City: </font><font style="font-size: 6pt"> </font>".$_POST['City']."<font size="2"> </font></font></td> </td> </tr> </table>"; echo fwrite($file,$body); fclose($file); ?> Parse error: syntax error, unexpected T_LNUMBER in /home/adfinanc/public_html/application/process.php on line 15 Quote Link to comment https://forums.phpfreaks.com/topic/166343-need-help-with-simple-application-form/#findComment-882850 Share on other sites More sharing options...
loveranger Posted July 25, 2009 Author Share Posted July 25, 2009 you may want to use css for this and use defined widths to make the columns lined up this is what you would be doing on a very basic level .columns { float:left; width:200px; } <div class="columns"> <?php echo "first name"; echo "address"; echo "province"; ?> </div> <div class="columns"> <?php echo "last name"; echo "city"; echo "postal code"; ?> </div> was asking for code to put in process.php Quote Link to comment https://forums.phpfreaks.com/topic/166343-need-help-with-simple-application-form/#findComment-882857 Share on other sites More sharing options...
lonewolf217 Posted July 25, 2009 Share Posted July 25, 2009 i have no idea where process.php is, but you can put this code anywhere you want Quote Link to comment https://forums.phpfreaks.com/topic/166343-need-help-with-simple-application-form/#findComment-882858 Share on other sites More sharing options...
loveranger Posted July 25, 2009 Author Share Posted July 25, 2009 See this is what I used for process.php <?php //Create a random 10-digit alphanumeric variable function randomgen() { $length = 10; $string = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $key = substr( str_shuffle($string), 0, $length ); return $key; } $filename = randomgen(); $file = fopen("$filename.html","w"); $body="<b>First name: </b> ".$_POST['First_name']." <b>Last Name: </b>" .$_POST['Last_name']."<br>"; $body.="<b>Address</b> ".$_POST['Address']." <b>City: </b>" .$_POST['City']."<br>"; echo fwrite($file,$body); fclose($file); ?> And this is what i get as output.... First name: dsfsdsf Last Name: dsfd Address dsfsd City: fsdfdsf As you can see Last Name and City are not aligned. Can you please modify my process.php so this can be achieved? Quote Link to comment https://forums.phpfreaks.com/topic/166343-need-help-with-simple-application-form/#findComment-882863 Share on other sites More sharing options...
loveranger Posted July 26, 2009 Author Share Posted July 26, 2009 Please help... Quote Link to comment https://forums.phpfreaks.com/topic/166343-need-help-with-simple-application-form/#findComment-883222 Share on other sites More sharing options...
elis Posted July 29, 2009 Share Posted July 29, 2009 <?php //Create a random 10-digit alphanumeric variable function randomgen() { $length = 10; $string = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $key = substr( str_shuffle($string), 0, $length ); return $key; } $filename = randomgen(); $file = fopen("$filename.html","w"); $body="<table width=\"75%\" cellpadding=\"2\" cellspacing=\"2\"> <td><b>First name: </b> ".$_POST['First_name']."</td><td> <b>Last Name: </b>" .$_POST['Last_name']."</td><tr>"; $body.="<td><b>Address</b> ".$_POST['Address']." </td> <td><b>City: </b>" .$_POST['City']."</td><tr> </table>"; echo fwrite($file,$body); fclose($file); ?> I haven't tested this though. There may be errors. Quote Link to comment https://forums.phpfreaks.com/topic/166343-need-help-with-simple-application-form/#findComment-886238 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.