• Can I design around a PHP form without mucking it up?
    17 replies, posted
  • Avatar of thirty9th
  • I'm attempting to add a nice cover home page to a website that currently functions only as a database and data entry form. I have neither the knowledge nor the experience to mess around with PHP, so I'm wondering if I could simply design a webpage in HTML around this form without screwing it over. Here's what it looks like in bare-bones: [code]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <title>Company Title</title> <meta http-equiv="content-type" content="text/html;charset=UTF-8" /> </head> <link href="style.css" rel="stylesheet" type="text/css" /> <body> <Br><Br> <div style="margin-left:20px; margin-top:20px; margin-right:0px; margin-bottom:0px"> <form action="login.php" enctype="multipart/form-data" method="POST"> <input type="submit" value="LOG IN >>" class="button3"> </form> </div> </body> </html> [/code] When one clicks the LOG IN button, it creates several forms and drop-down menus that allow the user to enter data. However, will I be able to design a simple HTML page around this? Or will the PHP scripts attempt to create the forms all over the place? I'm not quite sure how it works.
  • Avatar of Protocol7
  • You can use PHP to echo the desired code when necessary in your login.php, kind of like this: [code]/*HTML header shit goes here*/ <?php echo ('<input type="submit" value="Submit">'); ?> [/code] I'm not quite sure if that's the best way to go about it since I'm fairly new to the web programming thing but it's worked for me
  • Avatar of sseug
  • I have no idea what you're talking about but it sounds and looks like you need to learn HTML and PHP some more.
  • Avatar of turb_
  • [QUOTE=Protocol7;22709696]You can use PHP to echo the desired code when necessary in your login.php, kind of like this: [code]/*HTML header shit goes here*/ <?php echo ('<input type="submit" value="Submit">'); ?> [/code] I'm not quite sure if that's the best way to go about it since I'm fairly new to the web programming thing but it's worked for me[/QUOTE] What the fuck
  • Avatar of Protocol7
  • [QUOTE=turb_;22714957]What the fuck[/QUOTE] 1. You write HTML you want displayed 2. Echo it with PHP once they submit the form
  • Avatar of h2ooooooo
  • Why do you use parenthesis in echo? Why haven't you ended your input tag? Oh.. and what turb_ said
  • It looks like the only place where php comes into play is after you submit the form. Just keep the form action/method the same, and you should be just fine (even though all that form does is act as a link to login.php).
  • Avatar of Protocol7
  • I never said I was good at PHP so christ give me a fucking break and actually try helping the OP instead of correcting my own mistakes
  • Avatar of Zayfox
  • [QUOTE=Protocol7;22740863]I never said I was good at PHP so christ give me a fucking break and actually try helping the OP instead of correcting my own mistakes[/QUOTE] "I never said I was good at architecture so Christ give me a fucking break and try to help the guys that need a house instead of giving me shit 'cause the one I designed fell down."
  • Avatar of Protocol7
  • [QUOTE=Zayfox;22747252]"I never said I was good at architecture so Christ give me a fucking break and try to help the guys that need a house instead of giving me shit 'cause the one I designed fell down."[/QUOTE] that's completely different you fucking idiot if you have any common sense you'd know not to build a house if you know you can't something more insignificant like PHP is different because even if I do fucking suck at least I can have the gratitude of being one of the [B]THE VERY FEW PEOPLE IN THIS FORUM WITH THE COURAGE TO HELP THE OP[/B] even already knowing my PHP sucks. So grow up, quit chastising me because you spend more time coding than I do and just help the OP. I DO appreciate you guys trying to make the effort to better my PHP, but that's really not what's important here
  • Avatar of turb_
  • Shutup Protocol7, you shouldn't be trying to help if you have no fucking idea what you're on about.
  • Avatar of sseug
  • [QUOTE=Protocol7;22769698]that's completely different you fucking idiot if you have any common sense you'd know not to build a house if you know you can't something more insignificant like PHP is different because even if I do fucking suck at least I can have the gratitude of being one of the [B]THE VERY FEW PEOPLE IN THIS FORUM WITH THE COURAGE TO HELP THE OP[/B] even already knowing my PHP sucks. So grow up, quit chastising me because you spend more time coding than I do and just help the OP. I DO appreciate you guys trying to make the effort to better my PHP, but that's really not what's important here[/QUOTE] Yo yo simmer down. First of all, the mistake you made was one of simple logic - why would you echo an input with PHP instead of just putting it in as HTML? What does that solve? Second, jesus, stop making such a big deal out of this shit.
  • Avatar of Protocol7
  • [QUOTE=turb_;22771031]Shutup Protocol7, you shouldn't be trying to help if you have no fucking idea what you're on about.[/QUOTE] so then you help the OP you asshole
  • Avatar of CountNoobula
  • I am still not fully aware of what you are wanting... However I have the rough idea that you want to click login then get redirected to a page with alot of forms, etc... So use JavaScript, although now your actual login? I don't see any data to really submit(reason why I chose javascript, although PHP would work just as effectively) PHP Code to Redirect: [code]<?php header("Location: http://www.mysite.com/pagetogoto.html"); ?>[/code] JavaScript Code to Redirect: [code]<script language="javascript"> function login() { window.location = "http://www.mysite.com/" } </script>[/code] For the submit button for the JavaScript Method: [code]<input type="submit" onClick="login()" value="LOGIN"[/code] PS: If you go the JavaScript Method, may I recommend you remove the form or give the action attribute a "#" value. PPS: For a basic login system, you would need to create a form like this:[code]<form action="login.php" method="POST"><input type="text" size="20" name="user" /><br /><input type="password" size="20" name="pass" /><br /><input type="submit" value="Submit" /></form>[/code] Then for the "login.php" file, you would use code similiar to this: [code]<?php //Starts Session session_start; //Connects to Host $link = mysql_connect("hostname", "username", "password"); if($link) { //Selects Database $select = mysql_select_db("databasename"); if($select) { //Removes Special Characters from submitted data $user = mysql_real_escape($_POST['user']); $pass = mysql_real_escape($_POST['pass']); //Locates User $query = mysql_query("SELECT * FROM tablename WHERE user = '".$user."' AND password = '".md5($pass)."'"); $result = mysql_num_rows($query); if($result == 1) { //Gathers User Data from file $row = mysql_fetch_array($query); //Sets variable to check whether user is logged in on other pages //Just use a simple if($_SESSION['active'] == true) {perform actions} //REMEMBER TO START YOUR SESSION $_SESSION['active'] = true; //Uncomment one of the following to script lines //Redirects the user to a general page //header("Location: http://mysite.com/pagetogoto.html"); //Redirects the user to a per user page //header("Location: http://mysite.com/pagetogoto.php?id=".$row[id]); } else { echo "No user found."; } } else { echo "Could not select database"; } } else { echo "Could not connect to host"; } ?>[/code] Take note that script is very rough and would ofc need to be customised abit, hope it helps you abit though... PPPS: Apologies for any errors that it might contain... I was pressed for time, I can update it to be more accurate later if you so wish
  • Avatar of wutanggrenad
  • About the bickering that has occurred in this thread above me. I suggest for those that are beginning in any language to watch and wait for other more experienced programmers/designers to first post, usually their methods are better and make more sense. If no one does post, than feel free to post what your opinion/code. Anyone that has years of experience in any language knows that they have gotten better over time, and thought "man, I should've done it this way years ago"
  • [QUOTE=wutanggrenad;22815286]About the bickering that has occurred in this thread above me. I suggest for those that are beginning in any language to watch and wait for other more experienced programmers/designers to first post, usually their methods are better and make more sense. If no one does post, than feel free to post what your opinion/code. Anyone that has years of experience in any language knows that they have gotten better over time, and thought "man, I should've done it this way years ago"[/QUOTE] That's how I usually play the game in Web Development. I know I may be better than some, but I know there are several more commoners that are far more superior than I. I've been lurking here, learning the ways of the masters :v: