DeanWhitehouse Posted June 28, 2008 Share Posted June 28, 2008 how can i seperate a form input with that contains , and then insert into a database (i can do this bit). this is what i have so far. I tried exploding it, but if it is in an array how can i insert it into the db. if(isset($_POST['send'])) { $to = $_POST['to']; } ?> <!--<div id="title"><img src="title.jpg" alt="Title"></div>--> <div id="nav"></div> <form action="<?php $_SERVER['PHP_SELF']; ?>" method="post" class="email"> To <input type="text" value="<?php echo $to; ?>" name="to" size="100" onClick="this.value=''" title="Enter The Recipients Email Address"> </form> Quote Link to comment https://forums.phpfreaks.com/topic/112370-solved-mail-help/ Share on other sites More sharing options...
.josh Posted June 28, 2008 Share Posted June 28, 2008 what? Quote Link to comment https://forums.phpfreaks.com/topic/112370-solved-mail-help/#findComment-576923 Share on other sites More sharing options...
thatsgreat2345 Posted June 28, 2008 Share Posted June 28, 2008 You might want to clarify because I don't think anyone can understand what you are really asking for xD Quote Link to comment https://forums.phpfreaks.com/topic/112370-solved-mail-help/#findComment-576925 Share on other sites More sharing options...
DeanWhitehouse Posted June 28, 2008 Author Share Posted June 28, 2008 how can i seperate an input at (,) but not into an array. Quote Link to comment https://forums.phpfreaks.com/topic/112370-solved-mail-help/#findComment-576926 Share on other sites More sharing options...
.josh Posted June 28, 2008 Share Posted June 28, 2008 Well I don't really see anything in your posted code to do that to, so...what do we have to work with to begin with? Quote Link to comment https://forums.phpfreaks.com/topic/112370-solved-mail-help/#findComment-576930 Share on other sites More sharing options...
DeanWhitehouse Posted June 28, 2008 Author Share Posted June 28, 2008 Yer, i removed it , i first tried using strpbrk() but that is no longer used, i believe, then i tried using explode but that puts it in an array. Quote Link to comment https://forums.phpfreaks.com/topic/112370-solved-mail-help/#findComment-576932 Share on other sites More sharing options...
.josh Posted June 28, 2008 Share Posted June 28, 2008 but what I'm telling you is that in your form you only have one thing being submitted...so..I don't really see what you're trying to make a comma separated list out of...in other words..what are you trying to explode? What data/variable/whatever are you working with? Because you haven't provided that... Quote Link to comment https://forums.phpfreaks.com/topic/112370-solved-mail-help/#findComment-576933 Share on other sites More sharing options...
DeanWhitehouse Posted June 28, 2008 Author Share Posted June 28, 2008 the data in the form. it will be user submitted. Quote Link to comment https://forums.phpfreaks.com/topic/112370-solved-mail-help/#findComment-576934 Share on other sites More sharing options...
thatsgreat2345 Posted June 28, 2008 Share Posted June 28, 2008 Maybe you should post new code and explain what you expect since making sense of what you want from the code provided isn't exactly working out. Quote Link to comment https://forums.phpfreaks.com/topic/112370-solved-mail-help/#findComment-576939 Share on other sites More sharing options...
DeanWhitehouse Posted June 28, 2008 Author Share Posted June 28, 2008 <?php if(isset($_POST['send'])) { $to = "one,two,three"; // i need to split one,two,three into $one $two $three } ?> Quote Link to comment https://forums.phpfreaks.com/topic/112370-solved-mail-help/#findComment-576942 Share on other sites More sharing options...
thatsgreat2345 Posted June 28, 2008 Share Posted June 28, 2008 use preg_split and or split depending on the speed and complexity as you are just splitting by a comma you might as well use split. Quote Link to comment https://forums.phpfreaks.com/topic/112370-solved-mail-help/#findComment-576943 Share on other sites More sharing options...
.josh Posted June 28, 2008 Share Posted June 28, 2008 Okay, well, if you really are wanting variables to be named what's in your comma separated list like that: <?php $to = "one,two,three"; // i need to split one,two,three into $list = explode(',',$to); foreach($list as $val) { $$val = $val; } // example: echo $one; // echoes 'one' ?> however... I have a sneaking suspicion that your list is of emails, right? Well that's not going to really work out with emails. So...why can't you use an array? Quote Link to comment https://forums.phpfreaks.com/topic/112370-solved-mail-help/#findComment-576944 Share on other sites More sharing options...
DeanWhitehouse Posted June 28, 2008 Author Share Posted June 28, 2008 ok, thanks for all the reply's. Quote Link to comment https://forums.phpfreaks.com/topic/112370-solved-mail-help/#findComment-576945 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.