Web Dev Questions That Don't Need Their Own Thread v4
5,001 replies, posted
You should comment your code.
If I remember correctly, session_start(); has to be at the very top of the page. Try moving the include 'functions/functions.php'; to the very top of the page.
I'm unsure about this one though, but it's worth a shot.
[QUOTE=Svenskunganka;40921509]If I remember correctly, session_start(); has to be at the very top of the page. Try moving the include 'functions/functions.php'; to the very top of the page.
I'm unsure about this one though, but it's worth a shot.[/QUOTE]
[PHP] <?php include 'functions/functions.php'; ?>
<head>
<link rel="stylesheet" type="text/css" href="style/style.css">
</head>[/PHP]
Still doesn't work D: Thanks for trying though :D
I'm working on a php powered contact form and it uses 2 php files, one contains the form itself and the other file is form validation.
Above the form I use
[php]
<?php
// check for and display an error reported via the url
elseif (isset($_GET['e'])) echo "<div class=\"alert alert-error\">".$_GET['e']."</div>";
?>
[/php]
to check for errors and display a div reporting it. Works fine.
'e' is coming from this line in the validation code:
[php]
//encode the input error into the url and redirect to it
header('Location: contact.php?e='.urlencode($error)); exit;
[/php]
My problem however is that I would like to retain the values of the form if there is an error, and it seems that header('Location: ') redirects lose this form data and breaks my method of filling the value back in:
[php]
<input ... value="<?php if (isset($name)) echo $name; ?>" />
[/php]
How should I go about retaining the form values? Will I need to find a new way to report form input errors to do so?
[QUOTE=boshuajackman;40921539][PHP] <?php include 'functions/functions.php'; ?>
<head>
<link rel="stylesheet" type="text/css" href="style/style.css">
</head>[/PHP]
Still doesn't work D: Thanks for trying though :D[/QUOTE]
He's right though.
Try removing the indentation at the start of the file, before the php tags that activate the include.
[editline]6th June 2013[/editline]
I'm not sure why you have everything indented so much, but it's not needed.
[editline]6th June 2013[/editline]
[QUOTE=BradB;40921729]-snip to reduce length-
My problem however is that I would like to retain the values of the form if there is an error, and it seems that header('Location: ') redirects lose this form data and breaks my method of filling the value back in:
[php]
<input ... value="<?php if (isset($name)) echo $name; ?>" />
[/php]
How should I go about retaining the form values? Will I need to find a new way to report form input errors to do so?[/QUOTE]
Well. You could use sessions. Place
[php]session_start(); [/php] at the top of both files.
Then at the validationpage, you should do something like:
[php]
$_SESSION['value'] = $_POST['value'];
$_SESSION['something'] = $_POST['something'];
//Or use this instead to copy everything in an array:
$_SESSION['post'] = $_POST;
[/php]
And on the form page you do:
[php]
<input type="text" name="the_name" value="<?= $_SESSION['the_name'] ?>" />
//Or with the second version:
<input type="text" name="the_name" value="<?= $_SESSION['post']['the_name'] ?>" />
[/php]
[editline]6th June 2013[/editline]
What I usually do though is let the validation happen at the top of the form page.
That way I don't need to move the post values to the session, you can just call the $_POST directly.
Done, and used...
[php]
<?php echo htmlspecialchars($_SESSION['post']['contact_message']) ?>
[/php]
... inside the textarea. Thank ye kindly, I knew nothing about sessions before now! It feels good to be getting into php and this tiny amount of backend at last. I can't wait to make cool things with what I've learned today.
-snip-
I've been using CodeIgniter for a while and quite enjoying it, but I'm beginning to find it a bit bloated as such. Maybe it's just me.
What PHP frameworks would people recommend on this forum that are well documented and easy to use?
[QUOTE=benbb;40936253]I've been using CodeIgniter for a while and quite enjoying it, but I'm beginning to find it a bit bloated as such. Maybe it's just me.
What PHP frameworks would people recommend on this forum that are well documented and easy to use?[/QUOTE]
If you're familiar with CodeIgniter, give [url=http://laravel.com/]Laravel[/url] a try. It has a nice documentation and uses Composer for autoloading and its components.
Be aware though that many of the doc links from Google may be dead for a while as they replaced the v3 documentation with v4's documentation and some links changed.
I've heard lots of good things about Laravel. I used CakePHP when I was still writing PHP and enjoyed it., but that was a long time ago.
I've been using Laravel for a while now, I love it. It is [i]really[/i] flexible. You can easily code small REST APIs to large enterprise apps.
I love Laravel, too! Had nothing but good experiences with it, so to speak.
Thanks for the Laravel recommendation - been looking for something like this.
[QUOTE=Dragory;40937952]If you're familiar with CodeIgniter, give [url=http://laravel.com/]Laravel[/url] a try. It has a nice documentation and uses Composer for autoloading and its components.
Be aware though that many of the doc links from Google may be dead for a while as they replaced the v3 documentation with v4's documentation and some links changed.[/QUOTE]
I've read a blog article about that saying why Larvarel was good. Might take a look at that.
[quote]
$ sudo yum install php-devel
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
* base: mirror.fdcservers.net
* epel: mirrors.servercentral.net
* extras: mirror.serversurgeon.com
* updates: mirrors.gigenet.com
* webtatic: us-east.repo.webtatic.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package php-devel.x86_64 0:5.3.3-22.el6 will be installed
--> Processing Dependency: php(x86-64) = 5.3.3-22.el6 for package: php-devel-5.3.3-22.el6.x86_64
--> Processing Dependency: automake for package: php-devel-5.3.3-22.el6.x86_64
--> Processing Dependency: autoconf for package: php-devel-5.3.3-22.el6.x86_64
--> Running transaction check
---> Package autoconf.noarch 0:2.63-5.1.el6 will be installed
---> Package automake.noarch 0:1.11.1-4.el6 will be installed
---> Package php.x86_64 0:5.3.3-22.el6 will be installed
--> Processing Dependency: php-common(x86-64) = 5.3.3-22.el6 for package: php-5.3.3-22.el6.x86_64
--> Processing Dependency: php-cli(x86-64) = 5.3.3-22.el6 for package: php-5.3.3-22.el6.x86_64
--> Running transaction check
---> Package php-cli.x86_64 0:5.3.3-22.el6 will be installed
---> Package php-common.x86_64 0:5.3.3-22.el6 will be installed
--> Processing Conflict: php54w-common-5.4.15-1.w6.x86_64 conflicts php-common < 5.4.0
--> Finished Dependency Resolution
Error: php54w-common conflicts with php-common-5.3.3-22.el6.x86_64
You could try using --skip-broken to work around the problem
** Found 1 pre-existing rpmdb problem(s), 'yum check' output follows:
php54w-mcrypt-5.4.15-1.w6.x86_64 has installed conflicts php-mcrypt = ('0', '5.4.15', '1.w6'): php54w-mcrypt-5.4.15-1.w6.x86_64
[/quote]
Can't install php-devel with yum, any fix?
Remove the [i]php54w-common[/i] package.
Is it possible to create some sort of data system using only client side scripting? It would need to give the ability to edit databases, have a checkout kind of system, be able to give quotes, and able to keep data such as credit cards and stuff secure. I would also need to be able to change variables like delivery charges, TAX, VAT, etc on front end. Is this possible?
If I can't figure out a way to go about this, I'll just do it in flash. :v:
[QUOTE=Activeellis;40949916]Ah! I should also mention that it's not going to actually be processing any real data from any users, it's for an assignment. Nothing actually needs to be ordered, you just need to be able to add shit to your basket and when you click checkout it comes up with a little alert like "haha well done u bought items". Thanks though![/QUOTE]
I know the basics of Javascript very well and I know how it operates. What I don't know, however, is how I can put it to use. Can anyone suggest me a good series of tutorials about javascript because I literally can't do anything useful with it.
[QUOTE=Cowabanga;40947838]I know the basics of Javascript very well and I know how it operates. What I don't know, however, is how I can put it to use. Can anyone suggest me a good series of tutorials about javascript because I literally can't do anything useful with it.[/QUOTE]
Try making a sliding/fading gallery for your portfolio.
[QUOTE=CBastard;40948156]Try making a sliding/fading gallery for your portfolio.[/QUOTE]
[B]how[/B]
[editline]8th June 2013[/editline]
What I'm trying to say is, I know how Javascript works, I know the bare basics of it but I can't seem to find good tutorials that are a bit over the levels of basics like arrays and objects and whatnot.
[QUOTE=Cowabanga;40947838]I know the basics of Javascript very well and I know how it operates. What I don't know, however, is how I can put it to use. Can anyone suggest me a good series of tutorials about javascript because I literally can't do anything useful with it.[/QUOTE]
What is it that you want to do in Javascript?
[QUOTE=gokiyono;40949142]What is it that you want to do in Javascript?[/QUOTE]
Better interactivity to websites?
[QUOTE=Cowabanga;40949207]Better interactivity to websites?[/QUOTE]
Consider [URL="http://jquery.com/"]jquery[/URL] then.
[QUOTE=gokiyono;40949226]Consider [URL="http://jquery.com/"]jquery[/URL] then.[/QUOTE]
I've had jQuery in mind, yeah. Do you suggest a place where I can learn how to use it?
[QUOTE=Cowabanga;40949249]I've had jQuery in mind, yeah. Do you suggest a place where I can learn how to use it?[/QUOTE]
There I couldn't help you without getting killed.
[sp]I can't remember there being anything wrong with the w3schools one.[/sp]
I normally just Google what I need to use when I need to use it.
w3schools does jquery tutorials? that's actually new to me.
[editline]8th June 2013[/editline]
I'll check them out anyway, thanks mate.
[QUOTE=Activeellis;40947538]Is it possible to create some sort of data system using only client side scripting? It would need to give the ability to edit databases, have a checkout kind of system, be able to give quotes, and able to keep data such as credit cards and stuff secure. I would also need to be able to change variables like delivery charges, TAX, VAT, etc on front end. Is this possible?
If I can't figure out a way to go about this, I'll just do it in flash. :v:[/QUOTE]
You need to do more research on this, you need to be compliant with regulations in order to store credit card & payment data... here's a place to start your research on this: [url]http://stackoverflow.com/questions/51094/payment-processors-what-do-i-need-to-know-if-i-want-to-accept-credit-cards-on[/url]
Are you able to take payments via Paypal or Amazon Payments? Amazon payments is very easy to use and in some cases has less fees than Paypal.
[QUOTE=Lev;40949741]You need to do more research on this, you need to be compliant with regulations in order to store credit card & payment data... here's a place to start your research on this: [url]http://stackoverflow.com/questions/51094/payment-processors-what-do-i-need-to-know-if-i-want-to-accept-credit-cards-on[/url]
Are you able to take payments via Paypal or Amazon Payments? Amazon payments is very easy to use and in some cases has less fees than Paypal.[/QUOTE]
Ah! I should also mention that it's not going to actually be processing any real data from any users, it's for an assignment. Nothing actually needs to be ordered, you just need to be able to add shit to your basket and when you click checkout it comes up with a little alert like "haha well done u bought items". Thanks though!
[QUOTE=Activeellis;40949916]Ah! I should also mention that it's not going to actually be processing any real data from any users, it's for an assignment. Nothing actually needs to be ordered, you just need to be able to add !@#$%^&* to your basket and when you click checkout it comes up with a little alert like "haha well done u bought items". Thanks though![/QUOTE]
Ah ok, it sounded like you wanted store card data on the client side.
So for more info, look into the HTML5 local storage capabilities:
[url]https://encrypted.google.com/search?hl=en&q=client%20local%20data%20storage[/url]
[url]http://stackoverflow.com/questions/4789515/client-side-local-storage-of-data[/url]
[url]http://stackoverflow.com/questions/tagged/local-storage[/url]
HTH
[php]<table width="100%">
<tbody>
<tr valign="top">
<td width="33.3%">
<h3></h3>
<ul></ul>
<h3></h3>
<ul></ul>
<h3></h3>
<ul></ul>
<h3>
D
</h3>
<ul>
<li></li>
<li></li>
</ul>
<h3></h3>
<ul></ul>
<h3></h3>
<ul></ul>
<h3></h3>
<ul></ul>
</td>
<td width="33.3%"></td>
<td width="33.3%">
<h3></h3>
<ul></ul>
<h3></h3>
<ul></ul>
<h3></h3>
<ul></ul>
<h3></h3>
<ul></ul>
<h3></h3>
<ul></ul>
<h3>
Đ
</h3>
<ul>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</td>
</tr>
</tbody>
</table>[/php]
This is from [url]http://vi.avatar.wikia.com/wiki/Th%E1%BB%83_lo%E1%BA%A1i:B%C3%A0i_vi%E1%BA%BFt[/url] Due to some poor support for the Vietnamese alphabet, Đ comes at the end, rather than after D where it is supposed to be - this irritates my friend.
The structure of the code is represented above (note that many elements are left collapsed in my representation).
Any Javascript experts know how I would move the <h3>Đ</h3> behind the <h3>D</h3>, and also move the following UL? I am not able to manually edit the HTML.
Sorry, you need to Log In to post a reply to this thread.