php vraag

Gestart doorDesire8 reacties67 weergaven

9 berichten · pagina 1 van 1

Desire

Lid · Topicstarter

Berichten
4.367
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
dit is mijn code:

[COLOR= #0000BB]<?php[/COLOR]

[URL="http://www.php.net/include"]include[/URL] [COLOR= #007700]([/COLOR][COLOR= #DD0000]db_connect.php[/COLOR][COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]submit[/COLOR][COLOR= #007700]])){[/COLOR]

[COLOR= #0000BB]$name[/COLOR] [COLOR= #007700]=[/COLOR] htmlspecialchars[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]name[/COLOR][COLOR= #007700]]);[/COLOR]
[COLOR= #0000BB]$email[/COLOR] [COLOR= #007700]=[/COLOR] htmlspecialchars[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]email[/COLOR][COLOR= #007700]]);[/COLOR]
[COLOR= #0000BB]$topic[/COLOR] [COLOR= #007700]=[/COLOR] htmlspecialchars[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]topic[/COLOR][COLOR= #007700]]);[/COLOR]
[COLOR= #0000BB]$message[/COLOR] [COLOR= #007700]=[/COLOR] htmlspecialchars[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]message[/COLOR][COLOR= #007700]]);[/COLOR]

[COLOR= #0000BB]$errors[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700];[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$name[/COLOR][COLOR= #007700]) <[/COLOR] [COLOR= #0000BB]3[/COLOR][COLOR= #007700]){[/COLOR]

[COLOR= #0000BB]$errors[/COLOR] [COLOR= #007700].=[/COLOR]  [COLOR= #DD0000]Je naam is te kort<br />[/COLOR][COLOR= #007700];

}[/COLOR][URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$email[/COLOR][COLOR= #007700]) <[/COLOR] [COLOR= #0000BB]3[/COLOR][COLOR= #007700]){[/COLOR]

[COLOR= #0000BB]$errors[/COLOR] [COLOR= #007700].=[/COLOR]  [COLOR= #DD0000]Je emailadres is te kort!<br />[/COLOR][COLOR= #007700];

}[/COLOR][URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700](![/COLOR][URL="http://www.php.net/strstr"]strstr[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]@[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$email[/COLOR][COLOR= #007700])[/COLOR] or [COLOR= #007700]![/COLOR][URL="http://www.php.net/strstr"]strstr[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000].[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$email[/COLOR][COLOR= #007700])){[/COLOR]

[COLOR= #0000BB]$errors[/COLOR] [COLOR= #007700].=[/COLOR]  [COLOR= #DD0000]Vul een geldig emailadres in!<br />[/COLOR][COLOR= #007700];

}[/COLOR][URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$message[/COLOR][COLOR= #007700]) <[/COLOR] [COLOR= #0000BB]3[/COLOR][COLOR= #007700]){[/COLOR]

[COLOR= #0000BB]$errors[/COLOR] [COLOR= #007700].=[/COLOR]  [COLOR= #DD0000]Je bericht is te kort<br />[/COLOR][COLOR= #007700];

}[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$errors[/COLOR] [COLOR= #007700]!=[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700]){[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<div id="error">[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$errors[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]</div>[/COLOR][COLOR= #007700];

}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]

[URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO contact VALUES (
NULL,
"[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$name[/COLOR][COLOR= #007700]) .[/COLOR] [COLOR= #DD0000]",
"[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$email[/COLOR][COLOR= #007700]) .[/COLOR] [COLOR= #DD0000]",
"[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$topic[/COLOR][COLOR= #007700]) .[/COLOR] [COLOR= #DD0000]",
"[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$message[/COLOR][COLOR= #007700]) .[/COLOR] [COLOR= #DD0000]"
);
"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<div id="succes">Succesvol verstuurd. We sturen je zo snel mogelijk een email terug.</div>[/COLOR][COLOR= #007700];

}

}[/COLOR]

?>
<form method="post" action="?p=contact">
<table style="border: 0;">
<tr>
<td style="width: 150px;">
Naam:
</td>
<td>
<input type="text" name="name" />
</td>
</tr>
<tr>
<td style="width: 150px;">
Email:
</td>
<td>
<input type="text" name="email" />
</td>
</tr>
<tr>
<td style="width: 150px;">
Onderwerp:
</td>
<td>
<select name="topic">
<option value="Vragen">Vragen</option>
<option value="Adverteren">Adverteren</option>
<option value="Klachten">Klachten</option>
<option value="Opmerkingen">Opmerkingen</option>
</select>
</td>
</tr>
<tr>
<td style="width: 150px;">
Bericht:
</td>
<td valign="top">
<textarea name="message"></textarea>
</td>
</tr>
</table>

<input type="submit" name="submit" value="Versturen" />
</form>


hij moet opgeslagen worden in de database als er een mail verstuurt word alleen hij zegt elke keer vul een geldige emailadres in
0
Berichten
6.722
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Met htmlspecialchars() worden vreemde tekens, onder andere @, weg gehaald. Je haalt dus @ uit het email adres, dus hij staat er niet meer in! Verander regel 8 dus in dit:

$email = $_POST[email];
0
Desire

Lid · Topicstarter

Berichten
4.367
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
nog steeds hetzelfde
0
Berichten
6.722
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Regel 22 klopt ook niet. Je moet bij strstr eerst de string doen en dan de tekst die er in voor moet komen. Verander regel 22 dus in dit:

}elseif(!strstr($email, @) or !strstr($email, .)){
0
Desire

Lid · Topicstarter

Berichten
4.367
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
hij doet het maar nu krijg ik ditxd
Column count doesnt match value count at row 1
0
Berichten
6.722
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Is dat wel in dit bestand?
0
Desire

Lid · Topicstarter

Berichten
4.367
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Wiitse schreef:
Is dat wel in dit bestand?
volgens mij niet xd, voor demo moet je ff pmen
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Das SQL error
0
Desire

Lid · Topicstarter

Berichten
4.367
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
ja, los ik morgen op ik ga nu film kijke
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren